Issues with building a project with "Register for COM interop" for a 64-bit assembly
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.
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".
Visual Studio internally uses the 32-bit version of the assembly registration tool (Regasm.exe).
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
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.
Id. de artículo: 956933 - Última revisión: 08/18/2008 14:48:05 - Revisión: 1.0
- kbnomt kbrapidpub KB956933