static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) { try { GF.closeLoading(); Exception ex = (Exception)e.Exception; GF.doDebug("********** THREAD FATAL ERROR : " + Environment.MachineName + " **********"); GF.doDebug(" [" + ex.TargetSite.ToString() + "]"); GF.doDebug(ex.Message); GF.doDebug("\r\n\r\n" + ex.StackTrace); GF.doDebug("\r\n\r\nFile : " + new StackTrace(ex, true).GetFrame(0).GetFileName()); GF.doDebug("\r\n\r\nLine : " + new StackTrace(ex, true).GetFrame(0).GetFileLineNumber()); GF.submitErrorLog(); waitHandle.WaitOne(); } finally { if (currentProcess != null) { currentProcess.Kill(); } System.Environment.Exit(0); } }
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { try { GF.closeLoading(); Exception ex = (Exception)e.ExceptionObject; GF.doDebug("********** FATAL UNHANDLED EXCEPTION ERROR : " + Environment.MachineName + " **********"); GF.doDebug(" [" + ex.TargetSite.ToString() + "]"); GF.doDebug(ex.Message); GF.doDebug("\r\n\r\n" + ex.StackTrace); GF.doDebug("\r\n\r\nFile : " + new StackTrace(ex, true).GetFrame(0).GetFileName()); GF.doDebug("\r\n\r\nLine : " + new StackTrace(ex, true).GetFrame(0).GetFileLineNumber()); GF.submitErrorLog(); waitHandle.WaitOne(); /*MessageBox.Show("Whoops! Please contact the developers with the following" + " information:\n\n" + ex.Message + ex.StackTrace, + "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);*/ } finally { if (currentProcess != null) { currentProcess.Kill(); } System.Environment.Exit(0); } }