从64 .NET访问COM 86NET、COM

2023-09-02 10:21:45 作者:你的情已泛滥

我有,因为我的图书馆被编译到值为anycpu,在x64运行在x64服务器。我们需要访问其下的x86注册COM组件。我不知道有足够的了解COM和我的谷歌搜索是导致我一事无成。

I have an x64 server which, since my libraries are compiled to AnyCPU, run under x64. We are needing to access a COM component which is registered under x86. I don't know enough about COM and my google searches are leading me nowhere.

问:我可以用一个符号链接注册从64回到86的COM组件?我是否需要注册在x64 COM组件呢?我可以(在这里任何声明......)?

Question: Can I use a symbolic registry link from x64 back to x86 for the COM component? Do I need to register the COM component under x64 as well? Can I (any statement here...) ?

感谢。

推荐答案

如果一个组件在运行64位本地的,它不能加载过程中的一个32位的COM服务器,因为它是错误的排序过程。有一对夫妇的解决方案成为可能:

If a component is running x64-native, it can't load a 32-bit COM server in-process, because it's the wrong sort of process. There are a couple of solutions possible:

如果你能,建立的COM code 64位版本(这当然会在64位注册表中注册本身)。这是最干净的解决方案,但可能无法进行,如果你没有code为COM服务器。

If you can, build a 64-bit version of the COM code (which would of course register itself in the 64-bit registry). This is the cleanest solution, but may not be possible if you don't have the code for the COM server.

运行,而不是64位的.NET组件为32位x86。我假设你已经考虑并拒绝了这一个由于某种原因。

Run your .NET component as 32-bit x86, instead of x64. I assume you've already considered and rejected this one for some reason.

外的过程中使用的 COM代理主机的COM组件 DLLHOST.EXE。这将使调用COM服务器非常非常慢(他们现在会间Windows消息,而不是本地函数调用),但在其他方面透明的(你没有做什么特别的事情)。

Host the COM component out-of-process using the COM surrogate DLLhost.exe. This will make calls to the COM server much, much slower (they will now be interprocess Windows messages instead of native function calls), but is otherwise transparent (you don't have to do anything special).

如果服务器需要自定义代理存根而不是使用正常OLEAUT32一(非常罕见的,虽然)这可能不会是一种选择,因为不会有一个64位版本的代理权。只要它可以使用普通的OLE编组,你可以它注册为代理激活。

This probably won't be an option if the server requires a custom proxy-stub instead of using the normal oleaut32 one (very rare, though), since there won't be a 64-bit version of the proxy available. As long as it can use the ordinary OLE marshalling, you can just register it for surrogate activation.

 
精彩推荐
图片推荐