Not using strong named Enterprise Library assemblies?

Apr 4, 2009 at 12:59 PM
Hi.

I am wondering if I need to use the strong named assemblies of Enterprise Library (v3.1) in order to use EntLibContrib.Data.MySql.dll?

"EntLibContrib.Data.MySql.csproj" references the strong named assemblies of Enterprise Library, so does that mean my project needs to, too?

Or is there a way to "redirect" all bindings to the strong named assembly "Microsoft.Practices.EnterpriseLibrary.Data" in "web.config" to point to a specific (not strong named) assembly?

I am asking because I am currently getting the error below.

Thank you.


Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' could not be loaded.


=== Pre-bind state information ===
LOG: User = NT AUTHORITY\NETWORK SERVICE
LOG: DisplayName = Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
 (Fully-specified)
LOG: Appbase = file:///C:/Program Files/MyApp/WebApplication/
LOG: Initial PrivatePath = C:\Program Files\MyApp\WebApplication\bin
Calling assembly : EntLibContrib.Data.MySql, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Program Files\MyApp\WebApplication\web.config
LOG: Using host configuration file: \\?\C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet.config
LOG: Using machine configuration file from c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/MyApp/d25166fb/e24c2c47/Microsoft.Practices.EnterpriseLibrary.Data.DLL.
LOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/MyApp/d25166fb/e24c2c47/Microsoft.Practices.EnterpriseLibrary.Data/Microsoft.Practices.EnterpriseLibrary.Data.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/MyApp/WebApplication/bin/Microsoft.Practices.EnterpriseLibrary.Data.DLL.
WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

 

Stack Trace:


[FileLoadException: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   System.RuntimeTypeHandle._GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, Boolean loadTypeFromPartialName) +0
   System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) +64
   System.RuntimeType.PrivateGetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) +58
   System.Type.GetType(String typeName, Boolean throwOnError) +59
   Microsoft.Practices.EnterpriseLibrary.Common.Configuration.AssemblyQualifiedTypeNameConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) +71
   System.ComponentModel.TypeConverter.ConvertFrom(Object value) +48
   Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DbProviderMapping.get_DatabaseType() +26
   Microsoft.Practices.EnterpriseLibrary.Data.DatabaseCustomFactory.CreateObject(IBuilderContext context, String name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache) +77
   Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy.BuildUp(IBuilderContext context, Type t, Object existing, String id) +71
   Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +38
   Microsoft.Practices.ObjectBuilder.SingletonStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +157
   Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +38
   Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfigurationNameMappingStrategy.BuildUp(IBuilderContext context, Type t, Object existing, String id) +88
   Microsoft.Practices.ObjectBuilder.BuilderBase`1.DoBuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies) +206
   Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies) +136
   Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUp(IReadWriteLocator locator, String idToBuild, Object existing, PolicyList[] transientPolicies) +74
   Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp(IReadWriteLocator locator, IConfigurationSource configurationSource) +115
   Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp(IConfigurationSource configurationSource) +42
   Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.NameTypeFactoryBase`1.CreateDefault() +48
   Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase() +62
   MyApp.MyCode() +31

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053

Apr 6, 2009 at 1:35 AM
I tried to add this to web.config, but then I get a different error (below).

Any ideas?

Thank you.

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Practices.EnterpriseLibrary.Data" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        <codeBase version="3.1.0.0" href="Microsoft.Practices.EnterpriseLibrary.Data.dll"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

Server Error in '/MyApp' Application.
--------------------------------------------------------------------------------

The type 'EntLibContrib.Data.MySql.MySqlDatabase, EntLibContrib.Data.Mysql, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null' cannot be resolved. Please verify the spelling is correct or that the full type name is provided.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: The type 'EntLibContrib.Data.MySql.MySqlDatabase, EntLibContrib.Data.Mysql, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null' cannot be resolved. Please verify the spelling is correct or that the full type name is provided.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace:


[ArgumentException: The type 'EntLibContrib.Data.MySql.MySqlDatabase, EntLibContrib.Data.Mysql, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null' cannot be resolved. Please verify the spelling is correct or that the full type name is provided.]
   Microsoft.Practices.EnterpriseLibrary.Common.Configuration.AssemblyQualifiedTypeNameConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) +181
   System.ComponentModel.TypeConverter.ConvertFrom(Object value) +48
   Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DbProviderMapping.get_DatabaseType() +26
   Microsoft.Practices.EnterpriseLibrary.Data.DatabaseCustomFactory.CreateObject(IBuilderContext context, String name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache) +77
   Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy.BuildUp(IBuilderContext context, Type t, Object existing, String id) +71
   Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +38
   Microsoft.Practices.ObjectBuilder.SingletonStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +157
   Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +38
   Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfigurationNameMappingStrategy.BuildUp(IBuilderContext context, Type t, Object existing, String id) +88
   Microsoft.Practices.ObjectBuilder.BuilderBase`1.DoBuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies) +206
   Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies) +136
   Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUp(IReadWriteLocator locator, String idToBuild, Object existing, PolicyList[] transientPolicies) +74
   Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp(IReadWriteLocator locator, IConfigurationSource configurationSource) +115
   Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp(IConfigurationSource configurationSource) +42
   Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.NameTypeFactoryBase`1.CreateDefault() +48
   Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase() +62
   MyApp.MyCode() +31


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053
Apr 7, 2009 at 12:34 AM
I was able to resolve this by replacing calls to:

DatabaseFactory.CreateDatabase();

with my own method which basically does:

return new GenericDatabase(
                connectionString,
                DbProviderFactories.GetFactory(providerName));
Oct 19, 2011 at 10:39 AM

I am facing the similar issue in my application also. Could you please guide me if you can.....  Here is the error message i faced....

 

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Microsoft.Practices.EnterpriseLibrary.Logging, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null'
   at UCLES.FEAR.Helper.LoggingHelper.WriteTechnicalMethodTrace()
   at UCLES.FEAR.DataAccess.referenceDataAccess..ctor(String connectionString)
   at UCLES.FEAR.WebServices.DataAccessFactory.ReferenceDataAccess() in D:\Robin\RateManagerService\UCLES.FEAR.WebServices\DataAccessFactory.cs:line 45
   at UCLES.FEAR.WebServices.RatesManagerService.ReferenceDataSelectAll() in D:\Robin\RateManagerService\UCLES.FEAR.WebServices\RatesManager.asmx.cs:line 1950

=== Pre-bind state information ===
LOG: User = CHANGEPONDDC\Administrator
LOG: DisplayName = Microsoft.Practices.EnterpriseLibrary.Logging, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///D:/Robin/RateManagerService/UCLES.FEAR.WebServices/
LOG: Initial PrivatePath = D:\Robin\RateManagerService\UCLES.FEAR.WebServices\bin
Calling assembly : UCLES.FEAR.BusinessEntitiesDAO, Version=8.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\Robin\RateManagerService\UCLES.FEAR.WebServices\web.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/7d5af86d/e58a7638/Microsoft.Practices.EnterpriseLibrary.Logging.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/7d5af86d/e58a7638/Microsoft.Practices.EnterpriseLibrary.Logging/Microsoft.Practices.EnterpriseLibrary.Logging.DLL.
LOG: Attempting download of new URL file:///D:/Robin/RateManagerService/UCLES.FEAR.WebServices/bin/Microsoft.Practices.EnterpriseLibrary.Logging.DLL.
WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

   --- End of inner exception stack trace ---

Oct 19, 2011 at 10:44 AM

It seems you are missing a reference.

http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=10714

Oct 19, 2011 at 10:56 AM

HI,

   Thanks for your quick response. When run the exe file i faced this error.

" To Install Enterprise Library june 2005, You much have .net framework 1.1 installed in your system"

 

 

 

 

Oct 19, 2011 at 11:32 PM

install .net framework 1.1