Tuesday, September 4, 2007

Exception Handling .NET 2.0 - Microsoft Enterprise Library

There are lot of advantages if you use Exception Handling mechanism provided by Microsoft Enterprise Library for .NET 2.0 Framework

1. You can download the MSI Installer of Application Block for Exception Handlers from


The exception handling will catch the exceptions and make the developer to view as text file/ view the exception from event viewer of the system.

2. Add references to three DLLs to your project


to your bin folder of your project.

Import the namespaces into your project


using Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;


Imports Microsoft.Practices.EnterpriseLibrary.Logging
Imports Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging
Imports Microsoft.Practices.EnterpriseLibrary.ExceptionHandling

3. Wherever you have your catch blocks in your aspx page make this alteration


catch (Exception ex)
ExceptionPolicy.HandleException(ex, "Log Only Policy");



Catch ex As Exception
ExceptionPolicy.HandleException(ex, "Log Only Policy");

"Log Only Policy" ----> Is the key value which will be coming from web.config

4. In order to catch exceptions in event viewer, please follow these settings

Go to Web.config

Step 1 :

Step 2 :

Step 3 :

Above steps will make the error available in your Event Viewer.

To see event viewer error logged, go to start-settings->cotrol panel->Administrative tools->Event viewer-Application->Logged Error.

For assistance, feel free to email @ sharpeye500 at yahoo dot com


Vinoth said...

where are you from copy pasting this ?

seems to be copy paste error ...

Karthick said...

I donot copy & paste anything from anywhere...

I just copy from my brain & paste in my blog.....

Rajasekar said...

Getting the following error message when replicated the above specified code in my app. Plz help me out to solve this

"Unrecognized configuration section exceptionHandling"