AppDomain.CurrentDomain.UnhandledException doesn't always fire up
Posted
by Simon T.
on Stack Overflow
See other posts from Stack Overflow
or by Simon T.
Published on 2010-03-18T15:28:18Z
Indexed on
2010/03/18
15:31 UTC
Read the original article
Hit count: 541
.NET
I encountered an exception in our application that isn't handled at all. I really don't know what to look for to debug this problem since the application close immediately when this peculiar exception is thrown (even running from VS). The exception handling is setup that way:
[STAThread]
[LoaderOptimizationAttribute(LoaderOptimization.MultiDomainHost)]
static void Main()
{
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
Application.ApplicationExit += new EventHandler(ApplicationExitHandler);
Application.ThreadException += new ThreadExceptionEventHandler(ThreadExceptionHandler);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionHandler);
...
The thread from which the exception is thrown is started that way:
Thread executerThread = new Thread(new ThreadStart(modele.Exporter));
executerThread.SetApartmentState(ApartmentState.STA);
executerThread.Start();
Now, every unhandled exception thrown from that thread fire up our UnhandledExceptionHandler except the one I have problems with. Even if I catch the problematic exception and throw it again, the application closes silently. None of the 3 handlers (ApplicationExit, ThreadException, UnhandledException) get fired (breakpoints not hit).
There is nothing so exceptional in that exception (see details here: http://pastebin.com/fCnDRRiJ).
© Stack Overflow or respective owner