WPF - DispatcherUnhandledException似乎不起作用

Mal*_*olm 10 wpf exception-handling

我开始在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();
    }
Run Code Online (Sandbox Code Playgroud)

Dom*_*ton 5

这可能是因为你有调试器处理异常的方式 - 调试/异常......应该允许你准确配置你想要的处理方式.