unhandled exception by:Frank
|
Hi, I made a handler for unhandled errors. But before that is executed, VB.NET gives me the standard error window. In VB6 there was a setting (errortrapping) about handling errors in the design environment and classes, which should prevent the before mentioned behaviour. Does VB.NET have a setting like it? Or is there something else?
Thanks in advance Frank
|
| | Reply: by:One Handed Man \( OHM#\)
|
| | If your talking about type of global error handler for a forms code, you could try launching the form inside a try catch block.
OHM
|
| | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
|
| | How did you make this error handler? Did you add a handler to 'Application.ThreadException'?
-- Herfried K. Wagner [MVP]
|
| | Reply: by:Jay B. Harlow [MVP - Outlook]
|
| | Frank,
Where & how did you "made a handler for unhandled errors"?
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 AddHandler in your Sub Main.
For Windows Forms look at: System.Windows.Forms.Application.ThreadException event Use AddHandler in your Sub 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/issues/04/06/NET/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.
> gives me the standard error window. In VB6 there was a setting > (errortrapping) about handling errors > in the design environment and classes, which should prevent the before > mentioned behaviour. Does VB.NET have a setting like it? To have the IDE break on exceptions use "Debug - Exceptions" then select the "Common Language Runtime Exceptions" node in the tree. Change either the "When the exception is thrown" or "If the exception is not handled" option as needed. If you have a global exception handler per above, you will need to change the "When the exception is thrown" to "Break into the debugger", as the global handlers is handling the exception!
Note you can expand the "Common Language Runtime Exceptions" tree to change the settings for specific exceptions...
Hope this helps Jay
|
| | Reply: by:grimsbyarchers@lycos.com (chris in grimsby)
|
| | In the VS design environment, Click DEBUG menu and select EXCEPTIONS from the sub menu. This allows you to define what action to take when an exception is thrown and if it is not handled. You can define actions for individual exceptions also. Great if you are trying to track down a specific error in your app
|
0 Comments:
Post a Comment
<< Home