C ++调用C#COM互操作错误:HRESULT 0x80131509 [英] C++ calling C# COM interop error: HRESULT 0x80131509

查看:117
本文介绍了C ++调用C#COM互操作错误:HRESULT 0x80131509的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个C#COM互操作供c ++调用。
我已经通过regasm注册了dll和tlb文件。
一切顺利,直到有一天我更改了C#部分的代码(我没有更改接口的定义,只是实现有所更改)。 COM中的一个接口返回错误0x80131509。奇怪的是,它仅发生在某些计算机上(我开发的PC运行良好,因此无法调试此问题)。
我不太清楚C#COM如何与C ++一起工作,在我注册它们之后,我只知道它们在窗口注册表中创建键值(例如生成的regasm / regfile)。 C ++如何知道COM dll在哪里(搜索路径环境变量)?以及tlb文件在运行时有什么用途?

I create a C# COM interop for c++ to invoke. I have registered the dll and tlb file by regasm. everything goes well till one day i changed code of C# part (i didn't change the definition of interface, just implementation changed). one interface in COM returns an error 0x80131509. the strange thing is, it is only happened in some computers (my develop PC is works well so i can't debug this problem). I'm not really clear on how the C# COM worked with C++, after i registered them, i just know they create key value in window registry.(like what regasm /regfile generated). how c++ knows where the COM dll is(search path environment variables)? and what the use of tlb file in run time?

有什么建议吗?

推荐答案

我认为您的问题与注册表有关...您应该尝试在存在此问题的计算机中注销并注册(使用重排)您的dll。

I think that your problem is related to the registry... You should try to unregister and register (using regasm) your dll in the computers that are having this problem.

如果这不起作用,请在那些计算机上注销dll,然后使用regedit搜索并删除引用该dll的所有丢失的注册表项,然后再次注册您的dll 。您还可以在删除丢失的键后使用其中一个注册表清理程序,以确保您不会丢失任何内容。

If that doesn't work unregister the dll in those computers, than use regedit to search and delete any missing registry keys that refer to it, after that register your dll again. You could also use one of those registry cleaner programs after deleting the missing keys to guarantee that you didn't miss anything.

请记住,您应该始终在您的应用程序将使用的目录,并且应该只发生一次。如果需要注销dll,则始终应在用于注册的目录中进行操作。换句话说,一旦注册了dll,请勿移动

Remember that you should allways register a dll in the directory that it will be used by your application and this should happen only once. If you need to unregister a dll, then you should allways do it in the same directory that you used for the registration. In other words, once a dll is registered do not move it.

注意:如果您的dll与C ++不在同一路径上应用程序,它应该位于PATH环境变量中引用的目录中。

Note: if your dll is not on the same path as your C++ application it should be in a directory that is referenced in the PATH environment variable.

这篇关于C ++调用C#COM互操作错误:HRESULT 0x80131509的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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