类未注册....当尝试从非托管 C++ 调用托管 C# 库时

发布于 2024-08-04 20:37:50 字数 332 浏览 2 评论 0原文

我有一个 C# 库,用于非托管 C++ 代码中的 COM 对象。我使用 Visual Studio 的复选框“Register For Com Interop”注册了该库,并将 ComVisible 设置为 true。

将 tlb 导入到 C++ 应用程序中......当我运行它时,我得到一个“类未注册”......

这之前已经工作过,但是在我将 C# 项目的目录移动到不同的目录后,这种情况开始发生位置....是的,我在移动图书馆后确实重新注册了它。

我已经从注册表中删除了所有引用...我什至尝试对其执行 gacutil.exe /i...没有骰子。

有人知道如何解决这个问题吗?

I have a C# library that I am using for a COM object in unmanaged C++ code. I registered the library using Visual Studio's checkbox "Register For Com Interop" and set ComVisible to true.

imported the tlb to the C++ app..... when I run it, I get a "Class Not Registered"....

This has worked before, but this started happening after I moved the directory of my C# project to a different location.... yes I did re-register the library after I moved it.

I've removed all references from the registry... I 've even tried doing a gacutil.exe /i on it... no dice.

Anyone know how to fix this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

故人如初 2024-08-11 20:37:50

在托管代码中使用非托管对象的更好方法是使用 C++/CLI。您可以轻松地围绕本机对象创建托管包装器。

A better way of using unmanaged objects in managed code is to use C++ / CLI. You can easily create a managed wrapper around the native object.

裸钻 2024-08-11 20:37:50

如果您没有在托管对象上设置显式 CLSID,则移动和重建可能会生成新的 CLSID。确保您的非托管项目没有过时的类型库副本。

转到 HKCR\CLSID\{XXXX} 并确保托管对象的类注册指向正确的托管 dll。

If you don't have explicit CLSID set on your managed object, it's possible that the move and rebuild has generated a new CLSID. Make sure your unmanaged project does not have a stale copy of the typelib.

Go to HKCR\CLSID\{XXXX} and ensure that the class registration for the managed object points to the right managed dll.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文