public static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
// Create Trace Log
string FileName = GenerateFileName();
Exception Ex = e.ExceptionObject as Exception;
using (ExceptionForm EForm = new ExceptionForm(Ex, false))
{
try
{
// Try to generate a trace log
GenerateExceptionLog(FileName, Ex);
// Display the Exception Form
EForm.Message = "An unhandled exception was thrown while trying to preform the requested task.\r\n"
+ "A trace log was generated under the \"My Documents/BF2Stastistics\" folder, to "
+ "assist with debugging, and getting help with this error.";
EForm.TraceLog = FileName;
}
catch
{
EForm.Message = "An unhandled exception was thrown while trying to preform the requested task.\r\n"
+ "A trace log was unable to be generated because that threw another exception :(. The error message "
+ "for the trace log was stored in the program error log for debugging purposes.";
}
finally
{
EForm.ShowDialog();
Application.Exit();
}
}
}