using System; using System.Threading.Tasks; using System.Windows; namespace ownChat { public partial class App { protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); SetupExceptionHandling(); } private void SetupExceptionHandling() { AppDomain.CurrentDomain.UnhandledException += (s, e) => { new ExceptionWindow((Exception) e.ExceptionObject) { Owner = MainWindow }.Show(); }; DispatcherUnhandledException += (s, e) => { new ExceptionWindow(e.Exception) { Owner = MainWindow }.Show(); e.Handled = true; }; TaskScheduler.UnobservedTaskException += (s, e) => { new ExceptionWindow(e.Exception) { Owner = MainWindow }.Show(); e.SetObserved(); }; } } }