[英]How do I handle unhandled Application level exceptions in a WPF application?
I'm migrating an existing Winforms based application to WPF. 我正在将现有的基于Winforms的应用程序迁移到WPF。
For handling unhandled exceptions at the application level in my Winforms app, I did the following: 为了在Winforms应用程序中处理应用程序级别的未处理异常,我做了以下工作:
Application.ThreadException
+= new ThreadExceptionEventHandler(Application_ThreadException);
AppDomain.CurrentDomain.UnhandledException
+= new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
How do I go about handling these conditions in a WPF based application? 如何在基于WPF的应用程序中处理这些条件?
您可以处理Application的当前实例的事件DispatcherUnhandledException
:
Application.Current.DispatcherUnhandledException += (s,e) => {...};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.