Naveed Butt
Naveed Butt

Reputation: 2901

Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Common' or one of its dependencies

I have searched google for this and could not find the solution to the problem.

My Website references DAL (custom dll) which references Enterprise Library Data Access Components.

I have added the Enterprise Library from the NuGet Package Manager and when I try to build the Website this compilation error pops up:

Error 44 Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Common' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference

I have tried setting the Copy Local = True in the DAL for the Enterprise Library dlls and the dlls are transferred to the Bin directory of the website along with DAL dll, but still the error pops up.

Can anyone guide me on this....

Upvotes: 20

Views: 93380

Answers (6)

Mr None
Mr None

Reputation: 31

Remove the reference, delete the DLL from the bin folder and VS, and re-add the reference.

Upvotes: -1

ebrecha
ebrecha

Reputation: 1

Setting the PublicKeyToken values for each of the EnterpriseLibrary references in Web.Config fixed it for me.

Upvotes: 0

competent_tech
competent_tech

Reputation: 44961

The problem is that the DLL that you are using and the one that is referenced in your project are different. I'm not sure what the difference in the manifest is, but it could be version and/or public key.

You have a couple of things to try:

  1. Open the properties for the DLL reference in your project and set Version Specific to false.

  2. Remove the reference, delete the DLL from the bin folder, and re-add the reference.

  3. You could also have a different/incorrect version in your GAC. In order to make sure that you are always using a specific, known version create an assemblies folder relative to your project directory, copy the dll to that directory, and add a reference to the DLL in the assemblies directory rather than one in GAC or elsewhere on your machine. This will ensure that only the specific version that you have targeted for the application will be used rather than any version that is updated on your machine at a later time.

Upvotes: 12

jlo-gmail
jlo-gmail

Reputation: 5048

I was able to resolve this issue by removing from ALL the Logging references in the app.config file::

, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null

ie:

    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, 
Microsoft.Practices.EnterpriseLibrary.Logging, 
Version=6.0.0.0, Culture=neutral, PublicKeyToken=null" 
requirePermission="true" />

Becomes:

     <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, 
Microsoft.Practices.EnterpriseLibrary.Logging" 
requirePermission="true" />

This is not ideal, but it does work...

The Enterprise Library Configuration Tool, sets the values back, so you need to watch for that. I know there is a way to tell the config file to accept these mis-matched settings -- but I I am not sure how.

Upvotes: 1

Believe2014
Believe2014

Reputation: 3964

This dll is likely to be in the GAC on developer machines as part of some windows application installation (my best guesses are Visual Studio or SSMS). That’s why we are likely to get warnings or errors on the build machine which we try our best to keep the GAC as clean as the production server’s.

To download the file manually, you can go to https://servicelocation.codeplex.com/

To fix the build warnings and errors, you simply need to run a NuGet command to install the CommonServiceLocation package. The package contains only this one dll file. Microsoft has released only 1 version (1.0.0.0) of this file since 2008. The file is fully compatible with all .NET versions and all Unity versions.

Upvotes: 3

Bishoy Hanna
Bishoy Hanna

Reputation: 4589

NuGet CommonServiceLocator

Install-Package CommonServiceLocator

Upvotes: 3

Related Questions