I had a problem with the application freezing and setting the default message “Please inform Microsoft about this problem” instead of the “unhandled exception” dialog box in the application.
In the application code, Application.ThreadException and AppDomain.CurrentDomain.UnhandledException are redirected to a method that writes the error log to disk, saves the screenshot to disk, and displays a friendly dialog box.
But when this error occurs, none of these three things happen. All I get is in the event viewer:
EventType clr20e3, P1 myapp.exe, P2 4.0.0.0, P3 47d794d4, P4 mscorlib, P5 2.0.0.0, P6 471ebc5b, P7 15e5, P8 27, P9 system.argumentoutofrange, P10 NIL
Given that the error only occurs after the application has been running for several hours, I wonder if this could be a memory leak problem. I searched a bit for "clr20e3", but only could find ASP.Net stuff. My application is a Windows Forms (.Net 2.0) exe, using quite a few builds - both in C # and in some unmanaged C ++.
I suppose this could also be a mistake in the error handling method. As some answers show, I can try registering at the beginning of the error handler (but considering that this is pretty much what I do anyway ...).
Any help that solves this problem will be greatly appreciated - whether it be a solution or a suggestion on how to find out what is the main cause of the problem.
UPDATE: the main cause of the original error was access to an array with a negative index (this was the system.argumentoutofrange parameter). Why this was not trapped is a bit of a mystery to me, but considering that both exceptions were sent to the same processing code, I wonder if there could be a condition when (for example) both were called and fought for the resource ( e.g. log file)?
I managed to prove this by doing EventLog.WriteEntry first of all in the error handling code. By adding a flag to prevent re-writing in error handling, I no longer have a problem ...