Global Error Handling

O

OHM

Hi everyone,

I have a problem with error handling and wondered if anyone has managed to
implement a global exception handling model.

Is it possible to ensure that you see all exceptions before it becomes an
unhandled exception.

This is opposale to putting Try Catches around every statement

Regards - OHM
 
B

Brian Henry

global error handleing doesnt work in all instances... I have one over my
application but sometimes i get an error that is out of range of the error
handler and it catches the error at an unknown location or type but it still
caught the error. it seems if you want to get complete inormation you need
to do local exception checking and not over the whole app or the messages
returned may not be usasble in terms of debugging.
 
C

Cor Ligthert

Hi OHM,

Monday and tuesday there has been a very long and intresting arguing in the
newsgroup microsoft.public.dotnet.general

I do not know if it fullfils your needs. However I think it is worh for you
reading it

After a few starting messages it becomes very good in my opinion.

http://www.google.com/[email protected]

Cor
 
H

Herfried K. Wagner [MVP]

* "OHM said:
I have a problem with error handling and wondered if anyone has managed to
implement a global exception handling model.

Is it possible to ensure that you see all exceptions before it becomes an
unhandled exception.

This is opposale to putting Try Catches around every statement

<URL:http://www.google.de/[email protected]>
 
A

AlexS

Hi, OHM

you will catch all unhandled exceptions if you will enclose whole body of
your Main method in try-catch. However note this is valid only for main
thread. If you start other threads, you have to use try-catch in each thread
start delegate as well.

HTH
Alex
 
J

Jay B. Harlow [MVP - Outlook]

OHM,
In addition to the others comments.

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/default.aspx

Unfortunately the article is not on-line yet.

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top