Using custom exception handlers from a previous version of ent lib

Topics: Exception Handling Application Block
Jan 13, 2009 at 2:41 PM
I recently upgraded my project to Ent Lib 4.1, however, I have custom exception handlers that I wrote using Ent Lib 3.0.   I can use the 3.0 external config editor to add the 3.0 exception handler to my exception handling block in my app.config, but when the Ent Lib 4.1 ExceptionPolicy class comes across the 3.0 assembly it throws an error:

The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, Windows Exception Policy]) failed: Unable to cast object of type 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings' to type 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings'. (Strategy type ConfiguredObjectStrategy, index 2)

I assume this is because I'm using a 3.0 exception handler with the 4.1 ExceptionPolicy class.   Is there a way to do this or do I have to rebuild my custom exceptions handlers to use the 4.1 libraries?
Jan 14, 2009 at 8:55 AM
Hi,

I think there is a conflict between the referenced assemblies from the existing Custom Exception handler and the referenced assemblies of your project that is upgraded to 4.1. Maybe you can try rebuilding your Custom exception handler to reference the 4.1 assemblies and see if the error persist.


Hope this Helps.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com
Jan 14, 2009 at 1:52 PM
My thing is that I don't want two versions of my assembly.  I want to use my 3.0 Assembly with both applications that use Ent Lib 3.0 and other applications that use Ent Lib 4.1.
Jan 15, 2009 at 10:14 AM
I'm confused here, how were you able to add the 3.0 version of your custom handlers to your config file which uses 4.1?  Using 2 different versions of EntLib in a config file is not supported.


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com

Jan 15, 2009 at 1:48 PM
I used the external 3.0 config editor to create the 3.0 version of the config for my application which references the 4.1 DLLs.

My custom exception handler is used across several different applications.  Not all of the applications use the same version of Ent Lib.  I wanted to have one version of the custom exception handler that worked with all of them instead of having a copy compiled for each version of Ent Lib.
Jan 17, 2009 at 3:47 AM
Were all of your applications in the same machine? You have 2 versions installed in the same machine right? any EntLib dlls placed in gac? 


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Jan 27, 2009 at 6:34 PM
Edited Jan 27, 2009 at 6:35 PM
I want to use my 3.0 Custom Exception Handler with 4.1 Enterprise Library.   I do not want to upgrade my custom exception handler to 4.1.   Is there a way to do this?
Jan 28, 2009 at 12:26 PM
Hi,

What do u mean by "I used the external 3.0 config editor to create the 3.0 version of the config for my application which references the 4.1 DLLs", do you mean that you've created a config file with a 3.0 config and yet the application that is using that config is referencing 4.1 assemblies? I assume that you'll get a assembly mis match by doing that. Anyway, have you tried to do a bindingredirect? 


Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com
Jan 28, 2009 at 1:27 PM
Valiant:

That is exactly what I did and exactly the error I got.  I have not tried a binding redirect.  I will try that and let you know if it works.  Thanks.