This solution demonstrates two more advanced exception mangement techniques.
This sample contains two projects: a Windows Forms client and a Class Library.
Client
The client application has a reference to the class library. Two command buttons show how to execute methods against the customer class and catch the custom exceptions. A third command button causes an unhandled exception. In addition, there is a check box labeled 'Turn on Global Exception Trap' which when checked enabled a global exception trap. When enabled, the code defined in OnThreadException will be executed instead of the default Windows Form handler. Please see the comments for more information.
Requires the Trial or Release version of Visual Studio .NET Professional (or greater).
The program is best run outside the debugger to see the effects of a global exception handler. Run the program and click all three buttons. Note how Edit Customer and Delete Customer display nice error dialogs. Note that by default if you click the third button labeled Untrapped Local Error, a custom dialog appears. This dialog is the global exception handler defined by Windows Forms. Check the check box labeled 'Turn on Global Exception Trap' to see a custom trap in action.