1 using System
; // Exception
2 using System
.Text
; // StringBuilder
3 using System
.Windows
; // Application, MessageBox
4 using System
.Windows
.Threading
; // Dispatcher, DispatcherUnhandledExceptionEventArgs
8 public partial class App
: Application
10 void App_DispatcherUnhandledException(object sender
, DispatcherUnhandledExceptionEventArgs e
)
12 // Display exception message
13 StringBuilder sb
= new StringBuilder();
14 sb
.AppendFormat("{0}\n", e
.Exception
.InnerException
.Message
);
15 sb
.AppendFormat("{0}\n", e
.Exception
.Message
);
16 sb
.AppendFormat("Exception handled on main UI thread {0}.", e
.Dispatcher
.Thread
.ManagedThreadId
);
17 MessageBox
.Show(sb
.ToString());
19 // Keep application running in the face of this exception