protected override void OnStartup(StartupEventArgs e) { // hook on error before app really starts AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); base.OnStartup(e); }