Learn Something New …..Enterprise Library Configuration (Exception Handling Application Block)

Hi all,
today i have something really good to tell…”Enterprise Library Configuration 3.1 May 2007″

” Enterprise Library ” is having 4 application block , basically this a utility from Microsoft to reduce the Lines Of Code using these already built utilities .
Out of the 4 application block of Enterprise Library i was working on the
Exception Handling Application Block and
Logging Application Block

Now lets come to the point and learn how to use them .
First of all you need to install “Enterprise Library “. Once you install it than its easy enough to use Exception Handling Application Block and
Logging Application Block

Follow the steps : 1) Develop your application (say in asp.net with C#)
2) Add Configuration file to it (say wep.config)
3) Save it all.
4) Open Enterprise Library Configuration from Start Menu.
5) Open your application’s web.congif file . When you open it the whole project is Loded into Enterprise library’s MMC .
6) Now Right click on your project opened in EntLib and add a new application .
7) Right click on the newly added applcation and click on New and select Excception Handling Application Block
8) After adding it , right click on it and and add a new Policy .
9) Set the type of this new policy after addinf it .
10) Now Save all and swith back to your Project code , now web.congig file is changed and addded some tags. save it all.
11) Now thats it from EntLib ,now you just need to add some reference in your project as follows :

To use the basic features of the Exception Handling block, you need to reference the Microsoft.Practices.EnterpriseLibrary.Common.dll and Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll assemblies. If you need logging capabilities from within your exception management block, you will also need to reference the Microsoft.Practices.EnterpriseLibrary.Logging.dll assembly

12) Now add the name space
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling
For handling the exception :

// code
catch (someException ex)
bool rethrhrow= ExceptionPolicy.HandleException(ex, “ExceptionPolicy”);
if (rethrow)

you have done it..
Know More:

The Exception Handling Application Block includes four exception handlers:
• Wrap handler. This exception handler wraps one exception around another.
• Replace handler. This exception handler replaces one exception with another.
• Logging handler. This exception handler formats exception information, such as the message and the stack trace. Then the logging handler gives this information to the Enterprise Library Logging Application Block so that it can be published.
• Fault Contract Exception Handler. This exception handler is designed for use at Windows Communication Foundation (WCF) service boundaries, and generates a new Fault Contract from the exception.

Design Highlights
Figure : shows the interrelationships between the key classes in the Exception Handling Application Block


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s