private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { MessageBox.Show($"Unhandled exception in UI Dispatcher:\n\t{e.Exception.GetType()}: {e.Exception.Message}", "Unhandled UI Dispatcher exception in AnperiRemote", MessageBoxButton.OK, MessageBoxImage.Error); WpfUtil.TraceException("Unhandled exception in UI Dispatcher", e.Exception); try { HookManager.DisposeInstance(); } catch (Exception) { } Trace.Flush(); }
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { Exception ex = e.ExceptionObject as Exception; if (e.IsTerminating) { MessageBox.Show($"Unhandled exception occured:\n\t{e.ExceptionObject.GetType()}: {ex?.Message ?? "<Error getting exception message>"}\nExiting ...", "Unhandled exception in AnperiRemote", MessageBoxButton.OK, MessageBoxImage.Error); } WpfUtil.TraceException("Unhandled exception in AppDomain", ex); try { HookManager.DisposeInstance(); } catch (Exception) { } Trace.Flush(); }