Error being thrown when using Exception Handling

Topics: Enterprise Library Core, Exception Handling Application Block
Apr 1, 2014 at 1:08 PM
Hi, i'm getting the following error:

The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, Business Logic Layer]) failed: The type 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' cannot be resolved. Please verify the spelling is correct or that the full type name is provided.

When catching and rethrowing an error like this:

catch (Exception exp)
            bool rethrow = ExceptionPolicy.HandleException(exp, "Business Logic Layer");
            if (rethrow)
The name "Business Logic Layer" is a defined in the web.config exceptionHandling section.
I've added all the Enterprise Library references to my project, i'm using version 4.1.

Any help would be much appreciated.
Apr 1, 2014 at 1:21 PM
Probably the Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll is not being copied to the output folder because it is only referenced via the config file.

You could copy the assembly manually, or setup a post build command to copy the assembly to the output folder. Another alternative is to reference the assembly somewhere in your code (e.g. Type t = typeof(LoggingExceptionHandler);) so that visual studio will see dependency.

Randy Levy
Enterprise Library support engineer
Support How-to
Apr 3, 2014 at 8:47 AM
I tried removing and re-referencing dll's to my different projects, couldn't get it to work.

So I opted to upgrade from Enterprise Library 4 to Enterprise Library 6 and it now works fine.

Marked as answer by andyedwards12 on 4/3/2014 at 12:47 AM