Focus on Microsoft Technologies - Tutorials, Articles, Code Samples.

Thursday, August 31, 2006

.NET Exception Handling application block

Exception Handling application block
The Exception Handling application block contains optimized code for exception handling. You can download it here. It is encapsulated in the Microsoft.ApplicationBlocks.ExceptionManagement namespace. To use it, you must add a reference to the Microsoft.ApplicationBlocks.ExceptionManagement.dll.

The Exception Handling application block provides a way to manage exceptions in your applications. The main classes in this building block are the ExceptionManager, BaseApplicationException, and the ExceptionManagementSectionHandler class. A detailed view of the classes in this layer is shown in Figure C.

Figure C
Exception Handling block

Application exceptions are caught by the BaseApplicationException class. The ExceptionManager class is the key class. The ExceptionManager class has a Publish method used for handling the exception. This publishing mechanism is configured with an XML configuration file. Internally, the ExceptionManager class uses the ExceptionManagementSectionHandler class to retrieve the publisher settings from the XML configuration file. A default publisher logs the details of the Exception in the EventLog. You can also extend this building block by adding your own custom publishers. .

The only requirement is that these custom publishers should implement either the IExceptionPublisher or the IExceptionXmlPublisher interfaces. You can change the way the exceptions are published.

Continue updated Article…

, ,

Post a Comment