Visual Studio 2010 64-bit COM Interop Issue

依然范特西╮ 提交于 2019-12-18 11:48:03

问题


I am trying to add a VC6 COM DLL to our VS2010RC C# solution. The DLL was compiled with the VC6 tools to create an x86 version and was compiled with the VC7 Cross-platform tools to generate a VC7 DLL.

The x86 version of the assembly works fine as long as the consuming C# project's platform is set to x86. It doesn't matter whether the x64 or the x86 version of the DLL is actually registered. It works with both. If the platform is set to 'Any CPU' I receive a BadImageFormatException on the load of the Interop.<name>.dll.

As for the x64 version, I cannot even get the project to build. I receive the tlbimp error:

TlbImp : error TI0000: A single valid machine type compatible with the input type library must be specified.

Has anyone seen this issue?

EDIT:

I've done a lot more digging into this issue and think this may be a Visual Studio bug. I have a clean solution. I bring in my COM assembly with language agnostic 'Any CPU' selected. The process architecture of the resulting Interop DLL is x86 rather than MSIL.

May have to make the Interop by hand for now to get this to work.

If anyone has another suggestion let me know.


回答1:


This issue can be resolved by opening the CSProj file and adding the following node to any of the '(Configuration)|Any CPU' nodes that are missing it:

<PlatformTarget>AnyCPU</PlatformTarget>

If this node is not present TlbImp will default to x86 and cause issues.



来源:https://stackoverflow.com/questions/2450509/visual-studio-2010-64-bit-com-interop-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!