By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,558 Members | 1,673 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,558 IT Pros & Developers. It's quick & easy.

Debugger exception fallback

P: n/a
Nak
Hi there,

I'm just curious as to something. I have just added an exception
handler at the entry point to my application, within the IDE any unhandled
exceptions fallback to this and enable me to disable a dialog of my liking.
Now if I run the application outside of the IDE I recieve the standard
"Unhandled exception" dialog provided by .NET giving me the ability to
continue or quit.

I wasn't actually aware that exception handling differed in this way
outside of the IDE? Am I doing something wrong or is this normal procedure?
As my programs entry point is sub main(), surely I can just exception handle
this routine and catch any unhandled exceptions? I must have the wrong idea
about this, thanks in advance for any help!

Nick :-)
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Nick,
Now if I run the application outside of the IDE I recieve the standard
"Unhandled exception" dialog provided by .NET giving me the ability to
continue or quit. It doesn't sound like you are using a Global Exception handler, what does
your Sub Main look like?
I wasn't actually aware that exception handling differed in this way
outside of the IDE? Yes the IDE is able to stop your program exactly where the Exception is
thrown, allowing you to debug that location (check local variables & such).

Depending on the type of application you are creating, .NET has three
different global exception handlers.

For ASP.NET look at:
System.Web.HttpApplication.Error event
Normally placed in your Global.asax file.

For console applications look at:
System.AppDomain.UnhandledException event
Use add handler in your Main.

For Windows Forms look at:
System.Windows.Forms.Application.ThreadException event
Use add handler in your Main.

It can be beneficial to combine the above global handlers in your app, as
well as wrap your Sub Main in a try catch itself.

There is an article in the June 2004 MSDN Magazine that shows how to
implement the global exception handling in .NET that explains why & when you
use multiple of the above handlers...

http://msdn.microsoft.com/msdnmag/is...T/default.aspx

For example: In my Windows Forms apps I would have a handler attached to the
Application.ThreadException event, plus a Try/Catch in my Main. The
Try/Catch in Main only catches exceptions if the constructor of the MainForm
raises an exception, the Application.ThreadException handler will catch all
uncaught exceptions from any form/control event handlers.

Hope this helps
Jay

"Nak" <a@a.com> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl... Hi there,

I'm just curious as to something. I have just added an exception
handler at the entry point to my application, within the IDE any unhandled
exceptions fallback to this and enable me to disable a dialog of my
liking. Now if I run the application outside of the IDE I recieve the
standard "Unhandled exception" dialog provided by .NET giving me the
ability to continue or quit.

I wasn't actually aware that exception handling differed in this way
outside of the IDE? Am I doing something wrong or is this normal
procedure? As my programs entry point is sub main(), surely I can just
exception handle this routine and catch any unhandled exceptions? I must
have the wrong idea about this, thanks in advance for any help!

Nick :-)

Nov 21 '05 #2

P: n/a
Nak
Hi Jay,

Thanks for the information, that's just the ticket. I wonder how I
hadn't come across this sooner? Anyway, thanks thats great! :-)

Nick.

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:Ow**************@TK2MSFTNGP12.phx.gbl...
Nick,
Now if I run the application outside of the IDE I recieve the standard
"Unhandled exception" dialog provided by .NET giving me the ability to
continue or quit.

It doesn't sound like you are using a Global Exception handler, what does
your Sub Main look like?
I wasn't actually aware that exception handling differed in this way
outside of the IDE?

Yes the IDE is able to stop your program exactly where the Exception is
thrown, allowing you to debug that location (check local variables &
such).

Depending on the type of application you are creating, .NET has three
different global exception handlers.

For ASP.NET look at:
System.Web.HttpApplication.Error event
Normally placed in your Global.asax file.

For console applications look at:
System.AppDomain.UnhandledException event
Use add handler in your Main.

For Windows Forms look at:
System.Windows.Forms.Application.ThreadException event
Use add handler in your Main.

It can be beneficial to combine the above global handlers in your app, as
well as wrap your Sub Main in a try catch itself.

There is an article in the June 2004 MSDN Magazine that shows how to
implement the global exception handling in .NET that explains why & when
you
use multiple of the above handlers...

http://msdn.microsoft.com/msdnmag/is...T/default.aspx

For example: In my Windows Forms apps I would have a handler attached to
the
Application.ThreadException event, plus a Try/Catch in my Main. The
Try/Catch in Main only catches exceptions if the constructor of the
MainForm
raises an exception, the Application.ThreadException handler will catch
all
uncaught exceptions from any form/control event handlers.

Hope this helps
Jay

"Nak" <a@a.com> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl...
Hi there,

I'm just curious as to something. I have just added an exception
handler at the entry point to my application, within the IDE any
unhandled exceptions fallback to this and enable me to disable a dialog
of my liking. Now if I run the application outside of the IDE I recieve
the standard "Unhandled exception" dialog provided by .NET giving me the
ability to continue or quit.

I wasn't actually aware that exception handling differed in this way
outside of the IDE? Am I doing something wrong or is this normal
procedure? As my programs entry point is sub main(), surely I can just
exception handle this routine and catch any unhandled exceptions? I must
have the wrong idea about this, thanks in advance for any help!

Nick :-)


Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.