STom,
In addition to Tom's article:
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.
Something like:
Public Sub Main()
AddHandler Application.ThreadException, AddressOf OnThreadException
Application.Run(New MainForm)
End Sub
Private Sub OnThreadException(sender As Object, _
ByVal e As System.Threading.ThreadExceptionEventArgs)
Try
' Log the exception & possible show user the info...
Catch ex As Exception
' Don't want to end the app here! ;-)
End Try
End Sub
Using one (or more) of the above global handlers allows your application to
log the exception in the handler and allows your app to continue processing,
saving your from adding Try/Catch in each of your Form's event handlers for
example.
Hope this helps
Jay
STom said:
Thanks Tom for pointing me to the article...and thanks to everyone else for
their thoughts/opinions...I did not intend to start a war though
My thought behind try/catch is that if there is an exception, and the app is
going to halt anyway, how terribly important is it that it halts quickly?
For example, if the exception were thrown 8 levels deep and had to be
rethrown all the way back to the top, the app is going to probably appear to
hang for a short period of time before a message box or whatever displays
the error.
Thanks again.
STom
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/dotnetperftips.asp