无法加载文件或程序集“Microsoft.Practices.EnterpriseLibrary.Common"或其依赖项之一

Could not load file or assembly #39;Microsoft.Practices.EnterpriseLibrary.Common#39; or one of its dependencies(无法加载文件或程序集“Microsoft.Practices.EnterpriseLibrary.Common或其依赖项之一)
本文介绍了无法加载文件或程序集“Microsoft.Practices.EnterpriseLibrary.Common"或其依赖项之一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在 google 上搜索过,但找不到问题的解决方案.

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

我的网站引用了引用企业库数据访问组件的 DAL(自定义 dll).

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

我已从 NuGet 包管理器 添加了企业库,当我尝试构建网站时,会弹出此编译错误:

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

错误 44 无法加载文件或程序集Microsoft.Practices.EnterpriseLibrary.Common"或其依赖项之一.找到的程序集的清单定义与程序集引用不匹配

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

我已尝试在 DAL 中为 Enterprise Library dlls 设置 Copy Local = True,并且 dll 与 一起转移到网站的 Bin 目录>DAL dll,但还是会弹出错误.

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

推荐答案

问题是你使用的DLL和你项目中引用的DLL不同.我不确定清单中有什么区别,但可能是版本和/或公钥.

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.

你有几件事要尝试:

  1. 在项目中打开 DLL 引用的属性并将 Version Specific 设置为 false.

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

删除引用,从bin文件夹中删除DLL,重新添加引用.

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

您的 GAC 中也可能有不同/不正确的版本.为了确保您始终使用特定的已知版本,请创建一个相对于您的项目目录的程序集文件夹,将 dll 复制到该目录,并在程序集目录中添加对 DLL 的引用,而不是在 GAC 或其他地方添加对 DLL 的引用在你的机器上.这将确保仅使用您为应用程序指定的特定版本,而不是稍后在您的计算机上更新的任何版本.

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.

这篇关于无法加载文件或程序集“Microsoft.Practices.EnterpriseLibrary.Common"或其依赖项之一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)