繁体   English   中英

无法加载文件或程序集。 定位的程序集的清单定义与程序集引用不匹配

[英]Could not load file or assembly. The located assembly's manifest definition does not match the assembly reference

我正在尝试在蓝色棱镜中添加谷歌视觉 API 功能之一,但出现错误

“内部:无法执行代码阶段,因为代码阶段抛出异常:无法加载文件或程序集 'Google.Apis.Auth, Version=1.35.1.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab' 或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。(来自 HRESULT 的异常:0x80131040)”

但是提到的 dll 在 Blue Prism 文件夹中可用,我在初始化页面中添加了引用。 Google.Apis.Auth当前版本是1.40.2,但是我试过1.35.1.0版本,还是没有用。 我尝试添加另一个线程中提到的参考“Google.Cloud.PubSub.V1”,但这也不能解决问题。

带有此处提到的 dll 引用的以下代码在 Visual Studio 中运行良好,但在 blueprism 中运行良好。

请有人帮我解决这个问题

  var image = Image.FromFile("C:/New folder/Google VisionAI/otter_crossing.jpg");
  var client = ImageAnnotatorClient.Create();
  var response = client.DetectText(image);      

  foreach (var annotation in response)
  {
       if (annotation.Description != null)
       {
           Output = annotation.Description;
       }
  }        

这可能是依赖版本冲突,这意味着您的应用程序可能依赖于多个版本的程序集。 您可以尝试将程序集绑定添加到您的 app.config 文件或 web.config 文件(取决于您的项目类型),如下所示:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Google.Apis.Auth" publicKeyToken="4b01fa6e34db77ab" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-1.40.2.0" newVersion="1.40.2.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

基本上它在运行时说,任何依赖于 0.0.0.0-1.40.2.0 版本的“Google.Apis.Auth”的东西,使用 1.40.2.0 版本的程序集。 然后您可以参考最新版本。


正如错误所说,它找不到您想要的参考的特定版本; 因此,程序集之间可能存在不匹配。 您可以做几件事来排除故障:
1- 通过将其放入 GAC 或您的应用程序路径,确保它可以找到正确版本的参考。
2- 您也可以在 packages.config 或 web.config 中检查您的版本。
3- 在您的硬盘驱动器中搜索程序集,在结果页面中选择每个文件,查看属性中的详细信息选项卡并检查版本,以便您可以找到不需要的版本的来源。
4-删除bin文件夹并重建。
也检查这个链接

检查 Web 应用程序的 Web.config。 我看到了我的重复条目。 一个有全部大写的公共令牌。 所以我猜它是区分大小写的,并且在我升级版本时没有覆盖。 所以它一直使用旧版本号,我显然已经卸载了。 这可能是一种罕见的情况,但它可以帮助其他人。 希望这可以帮助。

这是存在的副本(如下)。

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="Google.Apis.Auth" publicKeyToken="4B01FA6E34DB77AB" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-1.27.1.0" newVersion="1.27.1.0" />
  </dependentAssembly>
<dependentAssembly>
    <assemblyIdentity name="Google.Apis.Auth" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-1.47.0.0" newVersion="1.47.0.0" />
  </dependentAssembly> </assemblyBinding>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM