-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.xaml.cs
36 lines (31 loc) · 1.29 KB
/
App.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Windows;
using System.Windows.Threading;
namespace Skelton.WpfMahAppsPrismReactiveProperty
{
public partial class App : Application
{
static readonly log4net.ILog Logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
DispatcherUnhandledException += Application_DispatcherUnhandledException;
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
}
protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
DispatcherUnhandledException -= Application_DispatcherUnhandledException;
AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException;
}
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Logger.Error(e.ExceptionObject as Exception);
}
private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
e.Handled = true;
Logger.Error(e.Exception);
}
}
}