2
votes

I am gettting the below error in MVC

[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=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'. Type B originates from 'Microsoft.Practices.EnterpriseLibrary.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.Practices.EnterpriseLibrary.Common\v4.0_6.0.0.0__31bf3856ad364e35\Microsoft.Practices.EnterpriseLibrary.Common.dll'.","ExceptionType":"System.InvalidCastException","StackTrace":" at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection.GetConfigurationSourceSection()\r\n at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceFactory.Create()\r\n

Please help in resolving the issue

1

1 Answers

0
votes

It seems you have a version conflict in Enterprise library versions.

You should be able to overcome this issue by adding a binding redirect to the later version in your web.config under <runtime><assemblyBinding>:

<dependentAssembly>
    <assemblyIdentity name="Microsoft.Practices.EnterpriseLibrary.Common" 
                      culture="neutral" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>

You may need to redirect any other EntLib assemblies in similar fashion.