반응형

App.xaml

DispatcherUnhandledException="Application_DispatcherUnhandledException"
<Application
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:TestApp"
             DispatcherUnhandledException="Application_DispatcherUnhandledException"
             x:Class="TestApp.App"
             StartupUri="View/Main/MainWnd.xaml">
    <Application.Resources>
 
    </Application.Resources>
</Application>

 

App.xaml.cs

private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
    Logger.Error(e.Exception.ToString());
 
    string errorMessage;
 
    errorMessage = e.Exception.Message;
 
    MessageBox.Show("An unhandled error occurred : " + errorMessage);
 
    e.Handled = true;
}
반응형

+ Recent posts