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

问题描述 投票:0回答:3

我正在尝试在蓝色棱镜中添加谷歌视觉 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;
       }
  }        
c# .net google-vision blueprism
3个回答
1
投票


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


1
投票

检查您的 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>

1
投票

这可能是依赖版本冲突,这意味着您的应用程序可能依赖于程序集的多个版本。您可以尝试将程序集绑定添加到您的 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 的程序集。然后就可以参考最新版本了。

© www.soinside.com 2019 - 2024. All rights reserved.