发行注册的x64组件为COM互操作 [英] Issue Registering x64 Assemblies for COM Interop

查看:377
本文介绍了发行注册的x64组件为COM互操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我公司开发的C#示例COM可见的DLL。
建于86,并通过32位Regasm注册,它是由COM客户端执行好。
内置64位,并通过64位Regasm注册,COM客户端调用生成以下错误:

I have developed a sample c# COM-Visible DLL.
Built in x86 and registered via 32-bit Regasm, it executes well by COM Client.
Built in x64 and registered via 64-bit Regasm, the COM Client call drops the following error :

Retrieving the COM class factory for component with CLSID {A0F2F58F-7B98-3605-BEC9-84724FF1E824} failed due to the following error: 80040154.

我检查并确保该CLSID为present确实下HKCR \ CLSID注册表。

I checked and made sure that CLSID is present indeed in the registry under HKCR\CLSID.

下面是通过模拟C#中的COM访问的例子:

Below is an example of simulating a COM Access via c# :

var type = Type.GetTypeFromProgID("ProgID.Interop.5683");
var obj = Activator.CreateInstance(type); // <-- blows here

我通过procmon中也检查了存在通过PROGID一个成功的访问类型 现在的问题是,哪里是激活看到底是什么?以及如何使它看到我的64位注册的组件?是不是我需要的地方增加?

I also checked via procmon that there is a successful access to the type via progId The question is, where is the Activator looking exactly ? and how to make it "see" my x64 registered assembly ? is there something I need to add somewhere ?

我发现有很多的解决方案建议在x86重新构建。但Come'on!我不打算这样做,并失去所有的x64好处只是COM的缘故。是否有一个真实的解决方案是什么?

I have found many "solutions" advising an x86 re-build. But Come'on ! I am not going to do that and lose all x64 benefits just for COM's sake. Is there a "REAL" solution to that ?

推荐答案

在睡觉,有点事后诸葛亮的一个晚上,我想通了,需要从一个64位应用程序调用激活,以通过查看发现64 CLSID在64的位置在注册表中。 也就是说,从一个x86应用程序调用时,Activaor看起来的CLSID和随后的关键,包括codeBase的在注册表中86的位置。

After a night of sleep and a little hindsight, I figured out that the Activator needed to be called from an x64 App, to find the x64 CLSID by looking in the x64 locations in the Registry. i.e, when called from an x86 App, Activaor looks in the x86 locations in the Registry for CLSID and subsequent key including codebase.

var type = Type.GetTypeFromProgID("ProgID.Interop.5683");
var obj = Activator.CreateInstance(type); 

这篇关于发行注册的x64组件为COM互操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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