【发布时间】:2010-09-28 07:08:02
【问题描述】:
我在 VS2008 中启动了一个新的 WPF 项目,然后添加了一些代码来捕获DispatcherUnhandledException。然后我给Window1添加了一个抛出异常
但错误没有被处理程序捕获。为什么?
public App()
{
this.DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
}
void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
System.Windows.MessageBox.Show(string.Format("An error occured: {0}", e.Exception.Message), "Error");
e.Handled = true;
}
void Window1_MouseDown(object sender, MouseButtonEventArgs e)
{
throw new NotImplementedException();
}
【问题讨论】: