全局异常处理程序WPF

时间:2015-09-18 12:15:15

标签: wpf exception

我正在尝试实现一个全局异常处理程序,当下一行生成错误时它会在调试器中停止时出现问题。

   var list = await _repository.GetAllAsync<ContactView>();

Application.Current.DispatcherUnhandledException +=
            new DispatcherUnhandledExceptionEventHandler(MainThreadExceptionHandler);
AppDomain.CurrentDomain.UnhandledException +=
          new UnhandledExceptionEventHandler(DomainExceptionHandler);

1 个答案:

答案 0 :(得分:1)

尝试按如下方式挂钩TaskScheduler.UnobservedTaskException

TaskScheduler.UnobservedTaskException += ( sender, eventArgs ) =>
{
    ...
};