469,358 Members | 1,628 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,358 developers. It's quick & easy.

Hide JIT Debug Error

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_Unhan dledException);
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();
}

Jul 21 '05 #1
4 2425
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.

Jul 21 '05 #2
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.

Jul 21 '05 #3
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:
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.

Jul 21 '05 #4
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.

Jul 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by John Black | last post: by
15 posts views Thread by Enzo | last post: by
4 posts views Thread by Jake | last post: by
2 posts views Thread by Badass Scotsman | last post: by
6 posts views Thread by Andrew Rowley | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.