// Catching All Errors in program.cs // if (!Debugger.IsAttached) { // if (!AppDomain.CurrentDomain.FriendlyName.EndsWith("vshost.exe")) { if (!Debugger.IsAttached) { Application.ThreadException += new ThreadExceptionEventHandler(HandleCrashes); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(HandleCrashes); }