>[STAThread] static void Main() > { > Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Root_Exception); > Application.Run(new MainWindow()); >} >private static void Root_Exception(object sender, System.Threading.ThreadExceptionEventArgs e) > { > //Handle exception here. >}But it's not good design to let most exceptions get this far. If you have a project that is likely to generate a specific exception it should be caught there. If it can't be handled then it can be re-thrown.....
#if !DEBUG // Don't use in debug mode. Application.Current.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Current_DispatcherUnhandledException); #endif