SqlExceptionWrap Handler with latest Entlib build

Topics: Development Team Discussion, User Discussion
Jan 9, 2012 at 8:26 AM

Hi all,

Working on a project for which it would be useful to map SQLExceptions to something a bit more useful/helpful. (Entlib 5 Update 1 with .Net 4 in Azure)

I downloaded the binary zipfile and dropped the .dll into the C:\Program Files (x86)\Microsoft Enterprise Library 5.0\Bin directory and the configuration extension initially appeared to work . ( I assume for this version config and functionality baked into a single DLL)


I can't seem to add SQL error codes and the settings don't look like the ones in the documentation (Though docs are for previous version)

Has anyone else tried to use the SQL Exception wrapper in this configuration?



Jan 9, 2012 at 4:42 PM

Hi Bryn,

Actually, you're right: it's not possible to specify the error codes through the EntLib v5 config tool :-(

If you're familiar with how the new config tool works, you'll notice that it's not possible for a custom provider that extend an official block (in that case, the SQL Exception Wrapper) to tweak the design-time for that block (like adding a 4th column to manage the error code collection).

My recommendation would be to configure the SQL Exception Wrapper as much as you can with the tool, and then add the ErrorCodes collection manually in XML.

Let me know how it goes. I'll post a QuickStarts project with a sample app.config file.



Jan 10, 2012 at 6:39 AM

Hi Bryn,

I Just checked-in a quick start sample application that shows how to configure and use the SQL Exception Wrapper + a fix related to the configuration support of the handler with the tool.

This new code is available under the Source Code section for now and will be included in the next release of the bin and source code packages.



Jan 19, 2012 at 11:46 AM

Thanks, it's great

a question, SQL Exception Wrapper supports ODP.NET 4.1 + EntlibContrib.Data.OdpNet ? thx again

Feb 3, 2012 at 8:16 AM

Hi kiquenet,

actually, the SQL Exception Wrapper strictly support SqlException.

As you can see below, the handler throw if an exception of another type is provided :

public Exception HandleException(Exception exception, Guid handlingInstanceId)
   SqlException sqlException = exception as SqlException;
   if (sqlException == null)
      throw new ExceptionHandlingException("The SqlExceptionWrapHandler can only operate on SqlException types.");