如何调试 C++由我的 DLL 引起的运行时错误?
我正在用 C# 为用 C++ 编写的主机应用程序编写一个插件 DLL(我没有主机应用程序的源代码)。当我运行主机应用程序时,它会加载我的 DLL 以供在该会话期间使用。最近,我在退出主机应用程序时看到以下错误:
Microsoft Visual C++ Runtime Library
Runtime Error!
Program: MyHostApp.exe
This application has requested the Runtime to terminate it in an unusual way...
此对话框仅包含“确定”按钮(没有调试按钮)。按“确定”后,主机应用程序退出,但不会给出任何可能导致错误的原因的指示。
我发现这个 stackoverflow 线程有类似的问题...
但是,每当我尝试将 VS2008 附加到崩溃的应用程序,然后按照指示执行“全部中断”时,我只会从 VS 收到以下消息:
“无法中断执行。此进程当前未执行您选择要调试的代码类型。”
我应该如何进行调试?
I'm writing an addin DLL in C# for a host application written in C++ (I do not have source for the host app). When I run the host application, it loads my DLL for use during that session. Recently, I've been seeing the following error upon exit of the host application:
Microsoft Visual C++ Runtime Library
Runtime Error!
Program: MyHostApp.exe
This application has requested the Runtime to terminate it in an unusual way...
This dialog only contains an "OK" button (no debug button). After pressing OK, the host app exits without giving any indication of what might have caused the error.
I found this stackoverflow thread with a similar problem...
How to debug a Visual C++ Runtime Error
But, whenever I try to attach VS2008 to the crashed application, and then do a "break all" as instructed, I only get the following message from VS:
"Unable to break execution. This process is not currently executing the type of code that you selected to debug."
How should I approach debugging this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试在启动调试器时设置“本机代码”选项?
Did you trying setting the "Native Code" option when starting the debugger?
C# 不生成本机代码!即使应用程序是本机应用程序,C# 也会在嵌套的 CLR 中执行。选择“托管代码”。
另外,不要“全部中断”,而是对所有可能的异常设置中断,然后运行到失败为止。
C# does not generate native code! Even if the app is native, C# is executed within nested CLR. Choose "Managed code".
Also, instead of "Break all", set a break on all possible exceptions, then run it to the failure.