Catching ALL Unhandled Exceptions

  • Thread starter Thread starter James Hancock
  • Start date Start date
J

James Hancock

I would like to have some way that if there is no error handling and an
exception is thrown in our application that it will do a last resort error
handling so that we can send information to support about the error.

Anyone have any ideas? I've tried putting a Try/catch around the
Application.run() command but it only works some of the time.

Thanks,
James Hancock
 
James Hancock said:
I would like to have some way that if there is no error handling and an
exception is thrown in our application that it will do a last resort error
handling so that we can send information to support about the error.

Anyone have any ideas? I've tried putting a Try/catch around the
Application.run() command but it only works some of the time.

You need a try/catch around the Application.Run and you need to add a
ThreadExceptionHandler to the Application.ThreadException event.

John Vottero
 
I believe that StackOverflowException and
OutOfMemoryException will still fall thru...
-----Original Message-----


You need a try/catch around the Application.Run and you need to add a
ThreadExceptionHandler to the
Application.ThreadException event.
 
James,
In addition to the other 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.

Hope this helps
Jay
 
Check out "Debugging Applications for Microsoft .NET and Microsoft Windows"
by John Robbins.
Microsoft Press ISBN 0-7356-1536-5

It's got a ton of information about how to provide exception monitoring and
reporting.

Mike
 
Back
Top