AppDomain.CurrentDomain.UnhandledException doesn't always fire up
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 un开发者_开发知识库handled 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).
You are working with OleDb provider which has calls to native code. If native code fails with some type of exceptions CLR can close the process silently. I've had common probles with OleDb provider for Sybase, I believe only some workarounds can help you, not a specific solution.
精彩评论