64位COM DLL和C#/。NET应用程序之间的免注册互操作 [英] Registration-free Interop between a 64-bit COM dll and a C#/.Net application

查看:296
本文介绍了64位COM DLL和C#/。NET应用程序之间的免注册互操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得一个64位COM DLL和C#应用程序的工作之间的免注册COM互操作。

I am trying to get registration-free COM interop between a 64-bit COM dll and a C# app to work.

<一个href="http://stackoverflow.com/questions/21332389/how-to-create-a-helloworld-com-interop-in-visual-studio-2012">In答案矿井的previous的问题,我得到了帮助,让我成功地呼吁64位COM DLL的C#一个HelloWorld方法。

In the answers to a previous question of mine, I got help that allowed me to successfully call a HelloWorld method on the 64-bit COM dll for C#.

然而,这是唯一可能通过使用登记,COM DLL全局使用regsrv32.exe。

However, this was only possible by registering the COM dll globally using regsrv32.exe.

在此基础上回答以一个相关的问题,我想我需要设置隔离标志上的参考在COM DLL来实现。然而,这导致了以下生成错误:

Based on this answer to a related question, I think that I need to set the Isolated flag on the reference of the COM dll to true. However, this leads to the following build error:

Problem isolating COM reference 'ComLibInteropLib': 
    No registered classes were detected for this component.

<一个href="http://social.msdn.microsoft.com/Forums/en-US/da74ff34-f34a-4889-b159-549808a49079/when-i-set-the-isolated-true-property-on-a-64-bit-com-dll-refernce-in-a-c-application-i-get-an"相对=nofollow>这个问题的答案在MSDN社会一个问题似乎表明,对于这个问题的解决方案,如果可以编译一个32位版本的DLL。

The answer to a question on MSDN social seems to indicate that there is a solution for this problem if one can compile a 32-bit version of the dll.

不过,我的COM互操作图书馆需要链接到一个'正常'的C ++ DLL,对此我没有来源,只能为64​​位。

However, my COM interop library needs to link to a 'normal' C++ dll, for which I do not have the source and that is only available as x64.

所以我的问题是:我怎样才能使隔离标志(或以其他方式获取并排方一道)64位COM DLL和C#应用程序之间?

So my question is: How can I enable the Isolated flag (or otherwise get side-by-side to work) between a 64-bit COM dll and a C# application?

我很乐意使用regsrv32.exe我的机器或其他开发人员的机器上,但我们不能对生产机器,在最终的应用程序必须运行注册任何COM DLL文件。

I am happy to use regsrv32.exe on my machine or other developer's machine, but we cannot register any COM dlls on production machines, where the final application must run.

推荐答案

这是你有,COM服务器没有得到正确注册原问题的一个副作用。当你隔离选项设置为true,构建系统自动生成所需的清单条目为您服务。但清单的内容需要来自的地方的,它使用的注册表项。因为它们不存在,就不能产生该清单

This is a side-effect of the original problem you had, the COM server wasn't getting registered properly. When you Isolated option to true, the build system auto-generates the required manifest entries for you. But the content of the manifest needs to come from somewhere, it uses the registry keys. Since they are not there, it can't generate the manifest.

您可以编写自己的清单,但需要足够的洞察力在什么清单应该像。随着犯错误非常高的赔率中,咒语相当模糊。所以避免这种情况,你只需要到网站注册并获得成功的COM服务器。只需在您的构建机器,它没有被注册的客户机上,因为它会使用清单。

You can write the manifest yourself but that requires enough insight in what the manifest should look like. With very high odds of making mistakes, the incantations are quite obscure. So avoid that, you just need to get the COM server registered to get ahead. Just on your build machine, it doesn't have to be registered on the client's machine since it will use the manifest.

您提到的64位COM服务器,这是另一种可能的故障模式。构建系统仍然是32位,所以你有很高的胜算,它看起来在错误的钥匙。 HKLM \ SOFTWARE \ Wow6432Node,而不是HKLM \ SOFTWARE。通过建立COM服务器的两种口味战斗中的问题。当心有同样的问题,当您使用Regsvr32.exe的自己,有他们两个。在C之一:\ WINDOWS \ SysWow64资料应该用于注册32位版本的服务器,并在c:\ Windows \ System32下的64位版本的

You mentioned a 64-bit COM server, that's another possible failure mode. The build system is still 32-bit so you'll have high odds that it looks at the wrong keys. HKLM\Software\Wow6432Node instead of HKLM\Software. Battle that problem by building both flavors of the COM server. Beware of having the same kind of problem when you use Regsvr32.exe yourself, there are two of them. The one in c:\windows\syswow64 should be used to register the 32-bit version of the server, the one in c:\windows\system32 for the 64-bit version.

这篇关于64位COM DLL和C#/。NET应用程序之间的免注册互操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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