473,320 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Debugger exception fallback

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
2 1289
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ken Varn | last post by:
I am trying to remote debug a C# application but the debugger is reporting the following exception: An unhandled exception of type 'System.IO.FileLoadException' occurred in Unknown Module....
9
by: RalphTheExpert | last post by:
I'm getting different behavior if my code is running under the debugger or not. I have modified Winmain to look like this: // Copyright (C) 2002 Microsoft Corporation // All rights reserved....
2
by: Chris Stiefeling | last post by:
Hi, I am experiencing a strange problem. I am reading and writing xml files via XmlDocument and XmlTextWriter. In the debugger everything works fine but outside the debugger (debug or release)...
1
by: Chris Stiefeling | last post by:
Hi, I am experiencing a strange problem. I am reading and writing xml files via XmlDocument and XmlTextWriter. In the debugger everything works fine but outside the debugger I receive the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.