我有一个 C# WPF UI 应用程序,当我关闭它时,我总是会看到一个 Windows 应用程序崩溃对话框(“UIDemo 遇到问题,需要关闭。”)。
错误报告表明这是一个 System.ObjectDisposeException,它表明在某个地方正在对已处置的对象调用方法。很好,我确实理解那部分。
我很想修复它。 我只是无法获得有关该混蛋的堆栈跟踪。
该异常正在逃避以下所有内容:
- 我的 DispatcherUnhandledException 处理程序
- 我的 try/catch 围绕退出事件处理程序的整个内容,
- 单击“调试” windows应用程序崩溃对话框将其关闭,并且不执行任何操作
- 在VisualStudio的调试模式下运行应用程序似乎可以工作,但是,奇怪的是,它似乎不会以这种方式崩溃,所以没有
任何痕迹我必须走on 是 Windows 发送给 MS 的错误报告的神秘内容。这些十六进制内存转储实际上并没有那么有用。
有谁知道我怎样才能得到那个该死的痕迹?
I have a C# WPF UI app, and when I close it, I always get a windows application-crash dialog ("UIDemo has encountered a problem and needs to close.").
The error report indicates that it's a System.ObjectDisposedException which indicates that somewhere a method's being called on a disposed object. That's fine, I do understand that part.
And I would love to fix it. I just can't get a stacktrace on the bastard.
That exception is evading all of the following:
- my DispatcherUnhandledException handler
- my try/catch surrounding the entire contents of the Exit event handler
- clicking "Debug" in that windows application-crash dialog closes it and doesn't do anything
- running the app in VisualStudio's Debug mode seems like it would work, but, strangely, it doesn't seem to crash this way, so no trace
All I have to go on is the arcane contents of the error report that Windows to send to MS. These hexidecimal dumps of memory aren't really that useful.
Does anyone know how I can get that darn trace?
发布评论
评论(3)
控制台窗口将显示抛出的任何异常以及完整的堆栈跟踪。要将控制台窗口添加到 WPF 应用程序:
Application
。输出类型
下选择控制台应用程序
。A console window will show any exceptions thrown with a full stack trace. To add a console window to your WPF application:
Application
.Output type
selectConsole Application
.另一种选择是使用 DebugDiag 捕获该特定异常并生成故障转储,可以通过 psscor2 或 SOS 在 WinDbg 中进行分析。这将允许您评估堆栈跟踪。
DebugDiag: http://www.microsoft.com/download /en/details.aspx?displaylang=en&id=24370
使用 WinDbg 调试 CLR:http://www.codeproject.com/KB/debug/windbg_part1.aspx
Another option would be to DebugDiag to catch that particular exception and generate a crash dump which could be analyzed in WinDbg via psscor2 or SOS. That will allow you to evaluate the stack trace.
DebugDiag: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=24370
Debugging CLR with WinDbg: http://www.codeproject.com/KB/debug/windbg_part1.aspx
尝试将 try/catch 放在 main 方法中,而不是在退出处理程序周围。在 WPF 中,main 方法并不总是很容易找到 - 请参阅此处了解如何找到它:http://joyfulwpf.blogspot.com/2009/05/where-is-main-method-in-my-wpf.html
Try putting a try/catch inside of your main method, not around the exit handler. In WPF, the main method isn't always easy to find- see here for how to find it: http://joyfulwpf.blogspot.com/2009/05/where-is-main-method-in-my-wpf.html