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

发布于 2024-12-19 23:55:33 字数 423 浏览 2 评论 0原文

我已经在谷歌上搜索过这个问题,但找不到问题的解决方案。

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

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

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

我尝试在Enterprise Library dlls的DAL中设置Copy Local = True并且DLL被传输到Bin网站目录以及DAL dll,但仍然弹出错误。

谁能指导我这件事......

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

拥有 2024-12-26 23:55:33

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

您可以尝试以下几项操作:

  1. 打开项目中 DLL 引用的属性,并将“版本特定”设置为 false。

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

  3. 您的 GAC 中也可能有不同/不正确的版本。为了确保您始终使用特定的已知版本,请创建一个相对于您的项目目录的程序集文件夹,将 dll 复制到该目录,并在程序集目录中添加对 DLL 的引用,而不是在 GAC 或其他地方添加对 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.

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.

风柔一江水 2024-12-26 23:55:33

NuGet CommonServiceLocator

Install-Package CommonServiceLocator

NuGet CommonServiceLocator

Install-Package CommonServiceLocator
贪恋 2024-12-26 23:55:33

该 dll 可能位于开发人员计算机上的 GAC 中,作为某些 Windows 应用程序安装的一部分(我最好的猜测是 Visual Studio 或 SSMS)。
这就是为什么我们可能会在构建机器上收到警告或错误,我们会尽力保持 GAC 与生产服务器一样干净。

要手动下载文件,您可以访问 https://servicelocation.codeplex.com/

来修复构建警告和错误,您只需运行 NuGet 命令即可安装 CommonServiceLocation 包。该软件包仅包含这一个 dll 文件。自 2008 年以来,Microsoft 仅发布了该文件的 1 个版本 (1.0.0.0)。该文件与所有 .NET 版本和所有 Unity 版本完全兼容。

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.

清风不识月 2024-12-26 23:55:33

我能够通过从 app.config 文件中的 ALL 中删除日志引用来解决此问题::

, 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" />

变成:

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

这并不理想,但它确实有效...

企业库配置工具,将值设置回来,因此您需要注意这一点。我知道有一种方法可以告诉配置文件接受这些不匹配的设置——但我不确定如何做。

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.

从﹋此江山别 2024-12-26 23:55:33

在 Web.Config 中为每个 EnterpriseLibrary 引用设置 PublicKeyToken 值为我解决了这个问题。

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

笑看君怀她人 2024-12-26 23:55:33

删除引用,从bin文件夹和VS中删除DLL,然后重新添加引用。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文