WPF全局异常处理程序 [英] WPF global exception handler
问题描述
有时候,在不可复制的情况下,没有任何消息,我的WPF应用程序崩溃。该应用程序只是瞬间关闭。
sometimes, under not reproducible circumstances, my WPF application crashes without any message. The application simply close instantly.
哪里是实施全球try / catch块的最佳场所。至少我要实现与一个消息:很抱歉给您带来不便......
Where is the best place to implement the global Try/Catch block. At least i have to implement a messagebox with: "Sorry for the inconvenience ..."
推荐答案
您可以处理<一href="http://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception.aspx"><$c$c>AppDomain.UnhandledException$c$c>事件
You can handle the AppDomain.UnhandledException
event
编辑:实际上,这个事件可能是更充分的:<一href="http://msdn.microsoft.com/en-us/library/system.windows.application.dispatcherunhandledexception.aspx"><$c$c>Application.DispatcherUnhandledException$c$c>
actually, this event is probably more adequate: Application.DispatcherUnhandledException
这篇关于WPF全局异常处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!