0040154类未注册(HRESULT异常:0x80040154(REGDB_E_CLASSNOTREG)) [英] 0040154 class not registered (exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))

查看:724
本文介绍了0040154类未注册(HRESULT异常:0x80040154(REGDB_E_CLASSNOTREG))的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的c ++项目中有一个idl文件我想在我用c#创建的第二个项目中为这个idl文件创建coclass实例。



在c#项目中创建该实例时,我在运行时获得了异常。



我在解决方案中搜索异常并且主要是我应该将构建平台设置为32位。



我尝试了什么:



I have an idl file in my c++ project I want to create instance for coclass from this idl file in my second project which I have created in c#.

while creating that instance in c# project I get the exception at runtime.

I search the solution for the exception and mostly got that I should set the build platform to 32 bit.

What I have tried:

引用:

我试过这个并用32位编译我的两个项目,但仍然得到了相同的异常。此外,当我编译64位平台上的两个项目仍然有相同的例外。



我也使用regsrv32注册我的c ++ dll,并在注册表中添加其条目64位。



我用C ++创建了单独的ATL项目,并试图在c#中创建一个coclass实例。这对我来说都是32位和64位。对于ATL项目,我没有运行任何命令来注册dll我认为visual studio为我做了这个。但对于我现有的非ATL项目,我无法在c#中实例化c ++ com类。

I tried this and compile my both project in 32 bit but still got the same exception. Also when i compile both the project on 64 bit platform still got the same exception.

Also I have register my c++ dll using regsrv32 and its entry is added in registry under 64 bit.

I have created separate ATL project in C++ and tried to create the instance of a coclass in c#. This work for me in both 32 bit and 64 bit. For the ATL project I did not run any command to register dll I think visual studio did that for me. But for my existing non ATL project I am not able to instantiate c++ com class in c#.

推荐答案

检查C + app是否为32或64位模式。有一些设置可以控制它。



当使用32位和64位dll时,命名和路径应该不同,因此系统不会使模块不匹配。检查所需的侧面装载的dll是否正确并且到位。



在ATL项目中,注册是标准构建过程中的批处理,因为项目向导已添加它。



听起来很愚蠢:错误代码是最好的提示有什么不对,问题是解释它们; - )
Check whether the C+ app is in 32 or 64 bit mode. There are some setting to control it.

When working with 32 and 64 bit dlls the naming and path should be different, so system isnt mismatching the modules. Check that the needed side loaded dlls are correct and in place.

In the ATL projects the registration is a batch in the standard build process because the project wizard added it.

As stupid as it sounds: the error codes are the best hint what is wrong, the problem is to interpret them ;-)


这篇关于0040154类未注册(HRESULT异常:0x80040154(REGDB_E_CLASSNOTREG))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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