CoCreateInstance 失败并出现错误“系统找不到指定的文件”
我有 .NET COM dll,我试图从非托管 C++ 代码加载它。我试图从我的代码中执行 CoCreateInstance
,但失败并出现错误“系统找不到指定的文件”。 (HRESULT 值为 0x80070002
)。为了查看组件的注册是否有任何问题,我尝试了测试器中的同一段代码。在那里我能够正确创建实例。另外,奇怪的是,在我的主应用程序的调试模式下,CoCreateInstance
成功,但仅在发布模式下失败。有谁知道可能出了什么问题或者我如何找到问题的根本原因?我已经在 dependency walker 中打开了 COM dll,并且没有显示任何错误。任何帮助将不胜感激。
I have .NET COM dll which I am trying to load from unmanaged C++ code. I am trying to do CoCreateInstance
from my code which fails with the error "System can not find the file specified". (HRESULT value is 0x80070002
). Just to see whether there are any problems with the registration of the component , I tried the same piece of code from my tester. There I am able to create the instance correctly. Also, strangely in the debug mode of my main application CoCreateInstance
succeeds but fails only in release mode. Does anybody has any idea what could be wrong or how can I find the root cause of the problem? I already opened the COM dll in dependency walker and it didn't show any errors. Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
COM 通常不会生成 ERROR_FILE_NOT_FOUND。但 CLR 确实会这样做,例如在尝试查找依赖程序集时很常见。请务必从 Release 构建目录运行 regasm /codebase。并使用 Fuslogvw.exe 来跟踪程序集解析问题。
COM doesn't normally generate an ERROR_FILE_NOT_FOUND. But the CLR certainly does, common when trying to find a dependent assembly for example. Be sure to run regasm /codebase from the Release build directory. And use Fuslogvw.exe to trace assembly resolution problems.