Enterprise library compatability

Topics: Data Access Application Block
Jan 28, 2009 at 12:08 PM
We have a webapplication that use entlib 2.0, but would like to upgrade that to use entlib 4.1.

I have downloaded the entlib 4.1 and added the assemblies to GAC, and are now in the process of changing my references to reference  the 4.1 assemblies.

When running my application, i get the following error, when trying to query my database:

Unable to cast object of type 'Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings' to type 'Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings'. Stack Trace: at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseConfigurationView.get_DatabaseSettings() at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseMapper.MapName(String name, IConfigurationSource configSource) at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfigurationNameMappingStrategy.BuildUp(IBuilderContext context, Type t, Object existing, String id) at Microsoft.Practices.ObjectBuilder.BuilderBase`1.DoBuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies) at Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies) at Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUp[TTypeToBuild](IReadWriteLocator locator, String idToBuild, Object existing, PolicyList[] transientPolicies) at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](IReadWriteLocator locator, IConfigurationSource configurationSource) at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](IConfigurationSource configurationSource) at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.NameTypeFactoryBase`1.CreateDefault() at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase() at....

The challenge is that we are still using VS2005 for this web application, so my question is, if this error appears because entlib 4.1 is not compatible with .net framework 2.0/vs2005

Jan 28, 2009 at 3:23 PM
Could be, version 4.x of EntLib was compiled and targeted at .NET 3.5.  However, the error looks more like a mismatch of entlib assemblies.  Do you have 2 versions of entlib installed? Or a different version of assembly installed in GAC other than the one you're using in your application? Make sure you reference the correct dlls.

For the compatibility concern with VS2005, see Chris Tavares' reply on this thread...http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=38830

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.