MS VS 调试器未捕获崩溃 - 如何捕获?
我的 C# 应用程序(Windows 7/VS2008)随机崩溃,它没有给我一个通常的堆栈跟踪,而是建议关闭/调试/查找信息 Windows 7 类型的对话框。我正在 VS2008 下运行该应用程序,或者独立运行该应用程序 - 同样的事情。单击“调试”建议使用 VS 的新实例进行调试,但由于“另一个调试器已附加到应用程序”而失败。但是附加的调试器没有给我任何机会查看它失败的地方,只是在输出窗口中提供一些线索(如下)。这该如何处理呢?
看起来我必须在 VS 调试器中启用(?)第一次机会异常,但不清楚如何......我感谢任何帮助!
另外 - 我发现了如何在 VS2008 中启用调试异常(调试 -> 异常 -> 检查所有 5 类异常)。它仍然给我完全相同的结果 - 崩溃而无法看到调试器中发生了什么。
“PS.exe”(托管):已加载 'C:\ Windows \程序集\ GAC_MSIL \ System.Deployment \ 2.0.0.0__b03f5f7f11d50a3a \ System.Deployment.dll' 类型的第一次机会异常 'System.Deployment.Application.InvalidDeploymentException' 发生在 System.Deployment.dll A 类型的第一次机会异常 'System.Threading.ThreadAbortException' 发生在 mscorlib.dll 线程 0x1964 已退出,代码为 0 (0x0)。 线程 0x1b24 已退出并带有代码 0 (0x0)。第一次机会例外 类型 'System.ArgumentOutOfRangeException' 首先发生在 mscorlib.dll A 中 类型的偶然异常 'System.ArgumentOutOfRangeException' 首先发生在 mscorlib.dll A 中 类型的偶然异常 'System.ArgumentOutOfRangeException' 首先发生在 mscorlib.dll A 中 类型的偶然异常 'System.ArgumentOutOfRangeException' 首先发生在 mscorlib.dll A 中 类型的偶然异常 'System.ArgumentOutOfRangeException' 首先发生在 mscorlib.dll A 中 类型的偶然异常 'System.ArgumentOutOfRangeException' 首先发生在 mscorlib.dll A 中 类型的偶然异常 'System.ArgumentOutOfRangeException' 首先发生在 mscorlib.dll A 中 类型的偶然异常 'System.ArgumentOutOfRangeException' 首先发生在 mscorlib.dll A 中 类型的偶然异常 'System.ArgumentOutOfRangeException' 首先发生在 mscorlib.dll A 中 类型的偶然异常 'System.ArgumentOutOfRangeException' 首先发生在 mscorlib.dll A 中 类型的偶然异常 'System.Threading.ThreadAbortException' 发生在 mscorlib.dll 线程 0x19b8 已退出,代码为 0 (0x0)。 线程 0x18f4 已退出并带有代码 0 (0x0)。线程 0x420 已退出 代码为 0 (0x0)。第一次机会 类型异常 'System.ArgumentOutOfRangeException' 首先发生在 mscorlib.dll A 中 类型的偶然异常 'System.ArgumentOutOfRangeException' 首先发生在 mscorlib.dll A 中 类型的偶然异常 'System.ArgumentOutOfRangeException' 首先发生在 mscorlib.dll A 中 类型的偶然异常 'System.ArgumentOutOfRangeException' 首先发生在 mscorlib.dll A 中 类型的偶然异常 'System.ArgumentOutOfRangeException' 首先发生在 mscorlib.dll A 中 类型的偶然异常 'System.ArgumentOutOfRangeException' 首先发生在 mscorlib.dll A 中 类型的偶然异常 'System.ArgumentOutOfRangeException' 首先发生在 mscorlib.dll A 中 类型的偶然异常 'System.ArgumentOutOfRangeException' 首先发生在 mscorlib.dll A 中 类型的偶然异常 'System.ArgumentOutOfRangeException' 首先发生在 mscorlib.dll A 中 类型的偶然异常 'System.ArgumentOutOfRangeException' 首先发生在 mscorlib.dll A 中 类型的偶然异常 'System.ArgumentOutOfRangeException' 首先发生在 mscorlib.dll A 中 类型的偶然异常 'System.ArgumentOutOfRangeException' 首先发生在 mscorlib.dll A 中 类型的偶然异常 'System.ArgumentOutOfRangeException' 首先发生在 mscorlib.dll A 中 类型的偶然异常 'System.ArgumentOutOfRangeException' 发生在 mscorlib.dll 程序中 “[6084] PS.exe:托管”已退出 代码为-1073740940 (0xc0000374)。
I'm getting random crashes from my c# app (Windows 7/VS2008), and it doesn't give me a usual stack trace, but rather suggests to close/debug/find info windows 7 kind of dialog box. I'm running the app either from under VS2008 or stand alone - same thing. Clicking "Debug" suggests to debug with a new instance of the VS, which fails as "another debugger's already attached to the app". But the attached debugger does not give me any chance to see where it fails, just gives some clues in the output window (below). How to deal with this?
It looks like I have to enable (?) first chance exceptions in the VS debugger, but it was unclear how.. I appreciate any help with this!
Addition - I found how to enable debugging the exceptions in VS2008 (Debug->Exceptions->checked all the 5 categories of exceptions). And it still gives me exactly the same result - crash without ability to see what's going on in debugger.
'PS.exe' (Managed): Loaded
'C:\Windows\assembly\GAC_MSIL\System.Deployment\2.0.0.0__b03f5f7f11d50a3a\System.Deployment.dll'
A first chance exception of type
'System.Deployment.Application.InvalidDeploymentException'
occurred in System.Deployment.dll A
first chance exception of type
'System.Threading.ThreadAbortException'
occurred in mscorlib.dll The thread
0x1964 has exited with code 0 (0x0).
The thread 0x1b24 has exited with code
0 (0x0). A first chance exception of
type
'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll A first
chance exception of type
'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll A first
chance exception of type
'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll A first
chance exception of type
'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll A first
chance exception of type
'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll A first
chance exception of type
'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll A first
chance exception of type
'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll A first
chance exception of type
'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll A first
chance exception of type
'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll A first
chance exception of type
'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll A first
chance exception of type
'System.Threading.ThreadAbortException'
occurred in mscorlib.dll The thread
0x19b8 has exited with code 0 (0x0).
The thread 0x18f4 has exited with code
0 (0x0). The thread 0x420 has exited
with code 0 (0x0). A first chance
exception of type
'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll A first
chance exception of type
'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll A first
chance exception of type
'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll A first
chance exception of type
'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll A first
chance exception of type
'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll A first
chance exception of type
'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll A first
chance exception of type
'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll A first
chance exception of type
'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll A first
chance exception of type
'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll A first
chance exception of type
'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll A first
chance exception of type
'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll A first
chance exception of type
'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll A first
chance exception of type
'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll A first
chance exception of type
'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll The program
'[6084] PS.exe: Managed' has exited
with code -1073740940 (0xc0000374).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
IMO 调试堆损坏的最佳方法是使用 Windbg。这是一个博客 Tess 发布的有关调试托管堆损坏的帖子。
华泰
IMO the best to debug heap corruptions is using Windbg. Here is a blog post from Tess on debugging managed heap corruption.
HTH
在 Visual Studio 中按
Ctrl
+Alt
+E
或选择“调试 >”从菜单中选择“异常”,然后单击“CLR 异常”以捕获所有第一次机会异常。那么,这应该有望在争论点被打破。否则,请尝试在代码中的关键点编写
Debug.Write
和Trace.Write
语句,以查看在发生故障之前到达的位置。 Debug 和 Write 都可以在 System.Diagnostics 命名空间中找到。Press
Ctrl
+Alt
+E
in Visual Studio or Choose Debug > Exceptions from the menu and then click CLR Exceptions to catch all first chance exceptions. That should then hopefully break at the point of contention.Otherwise, try write
Debug.Write
andTrace.Write
statements at critical points in your code to see what point you reach before the failure occurs. Both Debug and Write can be found inSystem.Diagnostics
namespace.如果开发工具失败,请创建一个输出日志文件或使用消息框来跟踪它。
create an output log file or use message boxes to track it down, if the development tool fails you.
在 VS 中,转到“调试/异常”,然后激活“公共语言运行时异常”的“抛出”下的复选框。这将捕获“第一次机会异常”。
部署异常似乎与 Click Once 有关。你在用它吗?
In VS, go to Debug / Exceptions, and activate the check box under 'Thrown' for 'Common language runtime exceptions'. This will catch the 'first-chance exception'.
A deployment exception seems to be related to Click Once. Are you using it ?
这有点像在一级方程式比赛中目睹一场大规模的连环相撞事故。最后一块弹片停下来报告说:
是的,这是一次非常严重的轮胎爆裂。当堆损坏时,很多事情都会出错。您可能有一些非托管代码,它们的行为异常是典型的非托管代码,通过错误的指针写入破坏了堆的完整性。很难诊断、隔离该代码。
It is sorta like witnessing one of those massive pile-ups at a formula 1 race. The last bit of shrapnel that came to a rest reported:
Yes, that's a very serious tire blow-out. Lots of things go wrong when a heap gets corrupted. You've probably got some unmanaged code that's misbehaving in a way that's so typical of unmanaged code, destroying the integrity of the heap with a bad pointer write. Very hard to diagnose, isolate that code.