从x64 .NET访问x86 COM [英] Access x86 COM from x64 .NET

查看:255
本文介绍了从x64 .NET访问x86 COM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个x64服务器,由于我的库编译成AnyCPU,运行在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.

问题:我可以使用符号注册表链接从x64回到x86 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...) ?

谢谢。

推荐答案

如果组件运行的是x64-native,则它无法在进程中加载​​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:


  1. 如果可以,构建64位版本的COM代码当然注册在64位注册表中)。

  1. 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.

将.NET组件作为32位元组件运行,但是如果你没有COM服务器的代码,位x86,而不是x64。

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代理 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(虽然很少见),这可能不会是一个选项, t是可用的代理的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.

这篇关于从x64 .NET访问x86 COM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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