问题描述
我想在我的C#应用程序遇到U-E时获取默认Windows窗体未处理的异常"对话框.在vs 2005中,当我关闭app.conf中的jit调试时,如下所示:
I want to get Default Windows Forms Unhandled-Exception Dialog whenever my C# application encounters U-E.In vs 2005 when I turn off jit Debugging in app.conf like this:
<configuration>
<system.windows.forms jitDebugging="false" />
<configuration>
该应用程序运行正常,并显示Windows窗体U-E默认对话框,其中包含继续",退出",调用堆栈"以及所有内容.
the application behaves correctly and shows Windows Forms U-E default dialog, with Continue, Quit, call stack and all.
但是,在vs 2008中,即使我禁用了jit,我仍然可以在同一台机器上或不同机器上使用调试",发送报告"和不发送"按钮获得默认的.NET Unhandled-Exception对话框.
However in vs 2008, on the same machine or different, even though I diable jit I still get Default .NET Unhandled-Exception Dialog, with Debug, Send Report and Don't Send buttons.
如何使vs 2008应用程序像在vs 2005中创建的应用程序一样显示Windows Forms U-E对话框?
How can I make my vs 2008 app act like the one I make in vs 2005, to show Windows Forms U-E dialog box?
请不要使用
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
仅仅因为我在vs 2005项目中不使用自定义处理程序,为什么在vs 2008中使用?我想让这份工作做CLR.
just because I don't use custom handler in my vs 2005 project, why would I use in vs 2008? I want to let this job do CLR.
感谢您的帮助
推荐答案
您正在谈论不同的异常处理功能.在退出并继续"中看到的 ThreadExceptionDialog 按钮由 Application.ThreadException事件.当响应Windows消息运行的事件处理程序引发异常时,只有在UI线程上发生异常时,它才会出现.但是,辅助线程中的任何异常都将通过AppDomain.UnhandledException轰炸程序.
您无法处理后者,程序已死,无法继续.显示ThreadExceptionDialog是没有意义的.
还请注意,使用调试器运行程序时,将禁用ThreadException事件.这大概就是为什么您在VS2008中看到差异的原因.否则没有任何变化.
这篇关于Windows窗体未处理的异常对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!