创建COM类的实例时出错 [英] Error creating instance of COM class

查看:85
本文介绍了创建COM类的实例时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试连接到远程服务器上的COM dll。



我的代码如下:



I'm trying to connect to a COM dll on a remote server.

My code is as follows:

Type type = Type.GetTypeFromProgID("ourType.ourClass", "ourServer", true);
Object instance = Activator.CreateInstance(type);





GetType工作正常,但CreateInstance会因以下错误而崩溃:





GetType works perfectly but CreateInstance falls over with the following error:

Retrieving the COM class factory for remote component with CLSID {ourCLSID} from machine ourServer failed due to the following error: 80040154.





我相当确信远程服务器上的对象是否正确注册。



从我到目前为止发现的,错误代码通常表明64位程序试图与32位对象通信时出现问题,建议的补救措施通常是重建x86的调用应用程序。我已经尝试过了(甚至尝试过针对.NET 2.0的测试)并且我仍然得到80040154错误。



有没有人遇到过这个?



I'm fairly confident that the object on the remote server is registered correctly.

From what I've found so far, the error code can often indicate problems with 64-bit programs trying to talk to 32-bit objects and the suggested remedy is usually to rebuild the calling application for x86. I've tried that (and even tried targeting .NET 2.0 for good measure) and I still get the 80040154 error.

Has anyone run into this before?

推荐答案

要尝试的事情......



1.下载Sysinternals [ ^ ]工具(特别是ProcMon和ProcExp) - 你可以找出是否有另一个DLL需要的问题没有正确注册(当我'时,它一直都是这个问题我遇到过类似的问题)



2.尝试重新注册DLL - 记住这需要在PC上注册而不是远程服务器,如果是32- bit需要使用%windir%\ SysWOW63 中的regsvr32.exe版本注册%windir%\ System32中的一个



3.如果两者都不是然后,这些工作使用ProcMon和其他sysinternals工具进一步了解正在发生的事情 - 请参阅链接以了解它们的工作原理。我确实推荐他们。
Things to try ...

1. Download the Sysinternals[^] tools (esp. ProcMon and ProcExp) - you can find out if there is another DLL that the problem one needs that isn't registered properly (it's always been this issue when I've come across similar problems)

2. Try re-registering the DLL - remember this needs to be registered on the PC not the remote server and if it is 32-bit needs to be registered with the version of regsvr32.exe that is in %windir%\SysWOW63 not the one in %windir%\System32

3. If neither of those work then use the ProcMon and other sysinternals tools to gain further insight into what is happening - see the link for details of how they work. I really do recommend them.


这篇关于创建COM类的实例时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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