【问题标题】:Could not load file or assembly System.ComponentModel.Annotations. The system cannot find the file specified无法加载文件或程序集 System.ComponentModel.Annotations。该系统找不到指定的文件
【发布时间】:2020-07-08 14:29:30
【问题描述】:

我正在使用程序集绑定,但我仍然收到此错误:

无法加载文件或程序集 'System.ComponentModel.Annotations, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 或其依赖项之一。系统找不到指定的文件

这是我的代码:

  <dependentAssembly>
    <assemblyIdentity name="System.ComponentModel.Annotations" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" />
  </dependentAssembly>

以下是有关错误的更多详细信息:

=== 预绑定状态信息 === 日志:DisplayName = System.ComponentModel.Annotations,Version=4.2.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a (完全指定) 日志:Appbase = file:///C://Source/Workspaces/CQB/Development/Dev-branch/Azure/CloudService1/csx/Debug/roles/CQB.TaskRole2/approot 日志:初始 PrivatePath = C:\Users\Source\Workspaces\CQB\Development\Dev-branch\Azure\CloudService1\csx\Debug\roles\CQB.TaskRole2\approot

调用程序集:Square.Connect,Version=2.25.0.0,Culture=neutral,PublicKeyToken=null。

LOG:此绑定在默认加载上下文中开始。 日志:使用应用程序配置文件:C:\Users\Source\Workspaces\CQB\Development\Dev-branch\Azure\CloudService1\csx\Debug\roles\CQB.TaskRole2\approot\CQB.TaskRole2.dll.config LOG:使用主机配置文件: LOG:使用 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config 中的机器配置文件。 LOG:在应用程序配置文件中找到重定向:4.2.0.0 重定向到 4.2.1.0。 日志:政策后参考:System.ComponentModel.Annotations,版本=4.2.1.0,文化=中性,PublicKeyToken=b03f5f7f11d50a3a 日志:尝试下载新的 URL 文件:///C://Source/Workspaces/CQB/Development/Dev-branch/Azure/CloudService1/csx/Debug/roles/CQB.TaskRole2/approot/System.ComponentModel.Annotations。动态链接库。 日志:尝试下载新 URL 文件:///C://Source/Workspaces/CQB/Development/Dev-branch/Azure/CloudService1/csx/Debug/roles/CQB.TaskRole2/approot/System.ComponentModel.Annotations/ System.ComponentModel.Annotations.DLL。 日志:尝试下载新的 URL 文件:///C://Source/Workspaces/CQB/Development/Dev-branch/Azure/CloudService1/csx/Debug/roles/CQB.TaskRole2/approot/System.ComponentModel.Annotations。 EXE文件。 日志:尝试下载新 URL 文件:///C://Source/Workspaces/CQB/Development/Dev-branch/Azure/CloudService1/csx/Debug/roles/CQB.TaskRole2/approot/System.ComponentModel.Annotations/ System.ComponentModel.Annotations.EXE。

【问题讨论】:

    标签: c# azure assembly-binding-redirect


    【解决方案1】:

    我发现库引用属性中显示的Version 4.5.0 版本是4.2.1.0。当我通过 NuGet 更改version to 4.4.1 时,属性中的版本更改为4.2.0.0

    因此,通过 nuget 将 System.ComponentModel.Annotations 的版本更改为 4.4.1 将为我解决问题。

    【讨论】:

      猜你喜欢
      • 2015-01-22
      • 1970-01-01
      • 2011-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-29
      相关资源
      最近更新 更多