There are some bugs I can't solved in My WinForm Application.
My WinForm Application process exit suddenly in abnormal with low probability, and it can't catch any exception before exit. The code of WinForm Application contain this:
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
Application.ThreadExit += new EventHandler(Application_ThreadExit);
AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);
In the function CurrentDomain_UnhandledException and Application_ThreadException, some logs is wrote and dump file is created, these function works if I throw exception on my own initiative. but they don't work while the WinForm exit suddenly in abnormal.
And The WinForm's Config contains this:
<?xml version="1.0"?>
<configuration>
...
<runtime>
<legacyCorruptedStateExceptionsPolicy enabled="true"/>
</runtime>
</configuration>
The WinForm Application's code is over Hundreds of thousands rows. I'm confused, I can't find where is wrong. Could somebody please help me to find the bugs ?
What I have tried:
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
Application.ThreadExit += new EventHandler(Application_ThreadExit);
AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);
<legacyCorruptedStateExceptionsPolicy enabled="true"/>