Richard
What you all essentially seem to be saying is that it is a design flaw to
ever let the exception go uncaught,
I would say the only "design flaw" is to not use Global Exception Handlers.
I also consider over using Try/Catch blocks to be a "design flaw" I only use
a Try/Catch when I have something specific to do with the exception, IMHO
logging the exception is not something specific as that can be handled by
the Global Exception Handlers. Nor is catching an exception simply to
rethrow it, as the normal Exception processing does this intrinsically.
A good use of Try/Catch is catching an UnauthorizedAccessException when
you're not authorized to a resource and you have a specific alternative
routine to use. Or the SQL Connection was closed due to network failure so I
need to create a new one...
I do, however, use a significant number of Try/Finally blocks to ensure
objects are properly disposed of. In VB.NET 2005 & current versions of C#
these Try/Finally blocks can be replaced with Using statements.
we cant
turn this dialogue off...
Incorrect, you can turn it off by using one or more of the Global Exception
Handlers, when you use a Global Exception Handler the standard dialog is not
displayed. The only exception (no pun intended) are any exceptions that the
constructor of the MainForm may throw, which is where you need a Try/Catch
around Application.Run in your Main. I normally include a Try/Catch around
the entire Main subroutine.
and we should instead
correct the design flaw that surrenders control to the framework when this
uncaught exception occurs?
No not quite... If you mean no Global Exception Handlers, then yes you need
to correct this design flaw & use Global Exception Handlers, if you mean not
enough Try/Catches then no using more Try/Catches would be a different kind
of design flaw...
Read the MSDN article I referenced in my other reply.
Hope this helps
Jay