developer 0

developer 0

  • NA
  • 8
  • 0

error handling

Sep 1 2004 6:00 PM
I am trying to find out why I am still getting the standard dialog about an unhandled exception, but I have handled the exceptions in main(). Here is my code: public static void Main(string[] Args) { try { foreach (string temptemp in Args) MessageBox.Show(temptemp); SplashScreen.ShowSplashScreen(); Application.Run(new frmMain()); } catch (Exception e) { Debug.WriteLine(e.ToString()); try { StreamWriter writer = new StreamWriter(Application.StartupPath + @"\error.log", true); writer.WriteLine("-------------------------------------------------------------------------"); writer.WriteLine(System.DateTime.Now.ToString()); writer.WriteLine("-------------------------------------------------------------------------"); writer.Write(e.ToString()); writer.WriteLine("\n\n"); writer.Close(); } catch (Exception){} Debug.WriteLine(e.ToString()); MessageBox.Show("An unexpected error has occured.\n\nPlease restart your computer and try again.\n\nIf the error persists, please contact Commonwealth Brands helpdesk", "Unexpected Error!", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error, System.Windows.Forms.MessageBoxDefaultButton.Button1); } } If I run the program from Visual Studio the code works like I would expect it should, it shows my message box. BUT if I run the program by double clicking on the application exe file, it shows the dialog box about an unhandled exception. Can anyone tell me how to fix this?