Issues with building a project with Register for COM interop for a 64-bit assembly

Issues with building a project with Register for COM interop for a 64-bit assembly

Article ID : 956933
Last Review : August 18, 2008
Revision : 1.0
Source: Microsoft Support

Back to the top

RAPID PUBLISHING

RAPID PUBLISHING ARTICLES PROVIDE INFORMATION DIRECTLY FROM WITHIN THE MICROSOFT SUPPORT ORGANIZATION. THE INFORMATION CONTAINED HEREIN IS CREATED IN RESPONSE TO EMERGING OR UNIQUE TOPICS, OR IS INTENDED SUPPLEMENT OTHER KNOWLEDGE BASE INFORMATION.

Back to the top

Action

While running on a 64-bit version of Microsoft Windows, you build a Visual Studio 2005 or Visual Studio 2008 project with the “Register for COM Interop” option selected, and the Target CPU type is set to “Any CPU” or x64.

Back to the top

Result

Based on the Target CPU type, one of the following conditions may occur:

1. If the Target CPU is “Any CPU”, the registry information is added to the 32-bit section of the registry. This may cause problems if you are writing extra information to the registry expect the information to be in the 64-bit section of the registry. For example, the  ComRegisterFunctionAttribute class can be used to write custom information to the registry.

 

 2. If the Target CPU is “x64” the build fails with the following error File <path to assembly> is not a valid assembly.

Back to the top

Cause

Visual Studio internally uses the 32-bit version of the assembly registration tool (Regasm.exe).

Back to the top

Resolution

To work around the problem, add a post build command to call the 64-bit version of RegAsm.exe using the following steps.

1. In the project properties, select “Build Events…” from the Compile page.

 

2. Add the following post build command line

%Windir% Microsoft.NET Framework64 v2.0.50727 regasm $(TargetPath)

 

Back to the top

DISCLAIMER

MICROSOFT AND/OR ITS SUPPLIERS MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY, RELIABILITY OR ACCURACY OF THE INFORMATION CONTAINED IN THE DOCUMENTS AND RELATED GRAPHICS PUBLISHED ON THIS WEBSITE (THE “MATERIALS”) FOR ANY PURPOSE. THE MATERIALS MAY INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS AND MAY BE REVISED AT ANY TIME WITHOUT NOTICE.

TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, MICROSOFT AND/OR ITS SUPPLIERS DISCLAIM AND EXCLUDE ALL REPRESENTATIONS, WARRANTIES, AND CONDITIONS WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO REPRESENTATIONS, WARRANTIES, OR CONDITIONS OF TITLE, NON INFRINGEMENT, SATISFACTORY CONDITION OR QUALITY, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE MATERIALS.

Back to the top


APPLIES TO
• Microsoft Visual Studio 2005 Standard Edition
• Microsoft Visual Studio 2005 Professional Edition
• Microsoft Visual Studio 2005 Team Suite
• Microsoft Visual Studio 2008 Standard Edition
• Microsoft Visual Studio 2008 Professional Edition
• Microsoft Visual Studio Team System 2008 Team Suite

Back to the top

Keywords: 
kbnomt kbrapidpub KB956933

Back to the top

   

Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
Microsoft Corporation. All rights reserved. Terms of Use | Trademarks


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Leave a Reply

*
To prove that you're not a bot, enter this code
Anti-Spam Image