I have a rather simple program that operates as an inventory tracking program. It is a single thread, .net 4.0, and is entirely event driven(nothing happens without a button click). The program crashes without a button being clicked. Here are the measures I have taken to attempt to get any information about this error:
FIRST: LOOK FOR UNHANDELED EXCEPTIONS OR THREAD EXCEPTIONS. CREATE A MESSAGE BOX POP-UP AND A DATABASE ENTRY FOR THIS ERROR:
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.Run(new archiveInventory_b());
}
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
MessageBox.Show(e.Exception.Message, "Unhandled Thread Exception");
ErrorLogEntry(e.Exception.Message + " INNER EXCEPTION: " + e.Exception.InnerException.Message, "ThreadException");
}
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
MessageBox.Show((e.ExceptionObject as Exception).Message, "Unhandled UI Exception");
ErrorLogEntry((e.ExceptionObject as Exception).Message + " INNER EXCEPTION: " + (e.ExceptionObject as Exception).InnerException.Message, "UnhandledException");
}
The program closes and no message box or database entry.
SECOND: CATCH THE CULPRIT IN THE ACT WHEN THE PROGRAM CLOSES:
private static void form_Closing(object sender, CancelEventArgs e)
{
const string message =
"Are you sure that you would like to close the program?";
const string caption = "Form Closing";
var result = MessageBox.Show(message, caption,
MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
// If the no button was pressed ...
if (result == DialogResult.No)
{
// cancel the closure of the form.
e.Cancel = true;
}
}
Yet no message ever appears. What else can be done to track this one down?