Home All Groups Group Topic Archive Search About

Hide JIT Debug Error

Author
7 Jun 2005 10:44 AM
Jake
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();
}

Author
8 Jun 2005 6:29 AM
Jeffrey Tan[MSFT]
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.
Are all your drivers up to date? click for free checkup

Author
13 Jun 2005 2:52 AM
Jeffrey Tan[MSFT]
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.
Author
13 Jun 2005 4:44 AM
Jake
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

""Jeffrey Tan[MSFT]"" wrote:

Show quoteHide quote
> 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.
>
>
Author
13 Jun 2005 5:34 AM
Jeffrey Tan[MSFT]
You are welcome :-)

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.

Bookmark and Share