Enterprise Library cast exception in web application

2.1k views Asked by At

I have a web application that uses Enterprise Library 4.1. A colleague upgraded an authentication module used by the web app to Enterprise Library 5.0. And unfortunately the upgraded version of the authentication module contains new functionality I need so I have to include the upgraded module in my project. I'm now getting the following exception:

 [A]Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection
 cannot be cast to [B]Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection.
 Type A originates from 'Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral,
 PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location
 'C:\Windows\assembly\GAC_MSIL\Microsoft.Practices.EnterpriseLibrary.Common\4.1.0.0__31bf3856ad364e35\Microsoft.Practices.EnterpriseLibrary.Common.dll'.
 Type B originates from 'Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral,
 PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location
 'C:\Windows\assembly\GAC_MSIL\Microsoft.Practices.EnterpriseLibrary.Common\5.0.414.0__31bf3856ad364e35\Microsoft.Practices.EnterpriseLibrary.Common.dll'.

Is there any way I can use the upgraded authentication module in my app without upgrading to EL 5.0?

1

There are 1 answers

1
Tim B On BEST ANSWER

I don't think that you can use both versions of Enterprise Library in an application at the same time, at least not when using configuration files. The problem you are seeing is due to version 5.0 attempting to read version 4.1 configuration sections from your application's configuration file.