>>[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 >Hi,
<Application x:Class=“Whatever.App” xmlns=“http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=“http://schemas.microsoft.com/winfx/2006/xaml” StartupUri=“MainWindow.xaml” DispatcherUnhandledException=“HandleUnHandled”> </Application>But you're right - better to not use it in Debug mode......