반응형

1. App.xaml에 DispatcherUnhandledException 추가

// App.xaml

<Application x:Class="Test.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             DispatcherUnhandledException="Application_DispatcherUnhandledException"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:Test">

2.  App.xaml.cs에 예외 발생시 처리 코드 추가

        private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            logger.Error(e.Exception.ToString());
  
            e.Handled = true;
        }
반응형

+ Recent posts