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

Naveed Butt picture Naveed Butt · Dec 8, 2011 · Viewed 70.6k times · Source

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....

Answer

competent_tech picture competent_tech · Dec 8, 2011

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.