Visual Studio 2010 64位COM互操作问题 [英] Visual Studio 2010 64-bit COM Interop Issue

查看:380
本文介绍了Visual Studio 2010 64位COM互操作问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图添加一个VC6 COM DLL到我们的VS2010RC C#解决方案。该DLL用VC6工具编译以创建x86版本,并使用VC7跨平台工具编译生成VC7 DLL。



x86版本的程序集工作正常只要消耗C#项目的平台设置为x86。不管x64或x86版本的DLL是否实际注册都没关系。它与两者协同工作。如果平台设置为任何CPU,我在 Interop。< name> .dll BadImageFormatException $ c>。



至于x64版本,我甚至不能让项目构建。我收到tlbimp错误:


TlbImp:错误TI0000:与
输入类型库兼容的单个有效机器类型必须


有人看到此问题吗?



p>

我做了更多的挖掘这个问题,认为这可能是一个Visual Studio错误。我有一个干净的解决方案。我带来了我的COM程序集与语言不可知'任何CPU'选择。所得Interop DLL的进程体系结构是x86而不是MSIL。



现在可以手动使用Interop。



如果任何人有另一个建议让我知道。

解决方案

这个问题可以通过打开CSProj文件并将以下节点添加到任何' (Configuration)|任何缺少它的CPU节点:

 < PlatformTarget> AnyCPU< / PlatformTarget> 

如果此节点不存在,TlbImp将默认为x86并导致问题。


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.

解决方案

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.

这篇关于Visual Studio 2010 64位COM互操作问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆