Custom Wrapper for enterprise library 5.0

Topics: Building and extending application blocks
Jul 13, 2011 at 12:40 PM

Hello all,

I need to use Enterprise library for exception logging in SQL Server 2005.

Now my queries here are that: 

  1. I would be getting the connection string from different place [not from web.config]. So i guess i need to write a wrapper class for connection. Can you suggest implementation way and the class details for it. 

  2. Other query is that, in one example i am using following line of code in catch block to log exception in db.<pre>bool s = ExceptionPolicy.HandleException(ex, "CustomException");</pre> Is this correct way? Do i have any better  alternative for it?? 

 3. If i want to change database table structure and stored procedure parameters for logging what should i do? Do i need to create wrapper classes by overriding the existing class of Enterprise library?Please suggest


Please suggest demo code. Thanks.

Jul 14, 2011 at 8:31 AM


Here are my answers:

1) If you will do it on runtime you can call the SqlDatabase class constructor and pass your connection string there.

          Database myDatabase = new SqlDatabase(myConnectionstring)

2) Yes you are correct. Just be sure you already added the Exception Logging Handler to your Exeption Handling Application Block.

3) You can create a custom database trace listener to achieve this one. If you want to, I can send you a sample database trace listener just drop as an email.


Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.