如何截取WPF应用程序中的NotImplementedException?如何在WPF应用程序中拦截NotImplementedException?
我会偶尔抛出一个NotImplementedException在测试我正在进行的WPF应用程序:
Private Sub ButtonDoSomething_Click(...) Handles ButtonDoSomething.Click
Throw New NotImplementedException(_
"ButtonDoSomething_Click() not implemented.")
End Sub
但是,我宁愿那些不引起程序崩溃。
我可以取代所有这些例外投用:
MessageBox.Show("ButtonDoSomething_Click() not implemented.", _
"Not Implemented", MessageBoxButton.OK, MessageBoxImage.Information)
但是,不知怎的,似乎inellegant如果NotImplementedException被埋葬离开界面是行不通的。
如何捕获所有这些异常并显示消息框?
不过,AppDomain.UnhandledException是由AppDomain在检测到未处理的异常时引发的事件。无论你做什么,该应用程序将立即关闭。 – 2009-02-12 21:25:40