Visual Studio 2010 64 位 COM 互操作问题
我正在尝试将 VC6 COM DLL 添加到我们的 VS2010RC C# 解决方案中。该DLL使用VC6工具编译以创建x86版本,并使用VC7跨平台工具编译以生成VC7 DLL。
只要使用 C# 项目的平台设置为 x86,x86 版本的程序集就可以正常工作。实际上注册的是 DLL 的 x64 版本还是 x86 版本并不重要。它适用于两者。如果平台设置为“任何 CPU”,我会在加载 Interop.
时收到 BadImageFormatException
。
至于 x64 版本,我什至无法构建项目。我收到 tlbimp 错误:
TlbImp:错误 TI0000:与 必须指定输入类型库。
有人见过这个问题吗?
编辑:
我对这个问题进行了更多的研究,认为这可能是一个 Visual Studio 错误。我有一个干净的解决方案。我引入了我的 COM 程序集,并选择了与语言无关的“任何 CPU”。生成的 Interop DLL 的进程架构是 x86 而不是 MSIL。
现在可能必须手动进行互操作才能使其正常工作。
如果有人有其他建议请告诉我。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可以通过打开 CSProj 文件并将以下节点添加到任何缺少该节点的“(配置)|任何 CPU”节点来解决此问题:
如果此节点不存在,TlbImp 将默认为 x86 并导致问题。
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:
If this node is not present TlbImp will default to x86 and cause issues.