Hide JIT Debug Error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to create an all encompassing error handler to handle all
Unhandled Exceptions. I have added an event handler to
AppDomain.CurrentDomain.UnhandledException and everything works fine when
debugging. When I try to run the app outside of the IDE I get the JIT Debug
message and my app never gets to the UnhandledException event. What am I
doing wrong??? Thanks in advance.

Sample code from a Windows App:

[Windows Stuff]

....
....
....

[STAThread]
static void Main()
{
AppDomain.CurrentDomain.UnhandledException += new
UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.Run(new Form1());
}

private static void CurrentDomain_UnhandledException(object sender,
UnhandledExceptionEventArgs e)
{
MessageBox.Show("Error!!!");
Application.Exit();
}

private void button1_Click(object sender, System.EventArgs e)
{
throw new Exception();
}
 
Hi jcarter,

Thanks for your post.

In .Net, the Winform has the build-in unhandled exception handler, which is
placed in an internal Application.OnThreadException method.(If you like,
you can use Reflector to view the implementation of this method). So we
should not use AppDomain.UnhandledException in Winform.

To override the build-in unhandled exception handling in Winform, we should
register Application.ThreadException event, then we can catch the unhandled
exception without any problem.

There is a great article writen by Jason Clark focusing on unhandled
exception handling in .Net, please refer to:
"Unexpected Errors in Managed Applications"
http://msdn.microsoft.com/msdnmag/issues/04/06/NET/

There is also some code snippet and a sample project do the demonstration
in this article.
=========================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi jcarter,

Does my reply make sense to you? Is your problem resolved? If you still
have anything unclear, please feel free to feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Jeffery,

Sorry, I've been busy and forgot to reply. Yes. I did get a chance to try
this out and it worked great. Thanks for your help.

:// Jake Carter
 
Back
Top