开发者

Preventing the "[YourProgramName] has stopped working" dialog on unhandled exceptions

开发者 https://www.devze.com 2022-12-28 20:19 出处:网络
I have a WinForm application, with some dependencies on an external library that can on occasion cause an exception outside of the running threads context.As it stands now, this is completely OK behav

I have a WinForm application, with some dependencies on an external library that can on occasion cause an exception outside of the running threads context. As it stands now, this is completely OK behavior ( well, except of course the exception ) and we wired up AppDomain.CurrentDomain.UnhandledException to simply restart the program.

The only problem is, the [Your Program] has stopped working like the one below, appears: alt text http://telcontar.net/store/archive/CrashGallery/images/crash/vista/2007-05-30%20Microsoft%20Register%20Server.png

Is there a way to prevent this dialog from appea开发者_高级运维ring at all, be it in the AppDomain unhandled exception handler or in a config setting, as no end users are going to be reading it and it just holds up resources until it is clicked.


Avoid the WER dialog by preventing your UnhandledException event handler from exiting. Call Environment.Exit() to terminate your app.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号