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

4
我正在尝试在Blue Prism中添加Google Vision API的功能,但是出现了错误。报错信息如下:“Internal: Could not execute code stage because an exception is thrown by code stage: Could not load file or assembly 'Google.Apis.Auth, Version = 1.35.1.0, Culture = neutral, PublicKeyToken = 4b01fa6e34db77ab' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)”。但是,该dll文件位于Blue Prism文件夹中,并且我已在初始化页面中添加了引用。当前版本的Google.Apis.Auth为1.40.2,但我尝试了版本1.35.1.0,仍然无效。我尝试添加“Google.Cloud.PubSub.V1”引用,如其他线程所述,但也无法解决此问题。下面的代码与此处提到的dll引用在Visual Studio中工作正常,但在Blue Prism中不起作用。请有人帮助我解决这个问题。
  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;
       }
  }        
3个回答

1
正如错误提示所说,它无法找到你想要的特定版本的引用;因此,程序集之间可能存在不匹配。 您可以执行以下几个步骤来进行故障排除:
1- 确保通过将其放入GAC或应用程序路径中找到正确的引用版本。
2- 您还可以在packages.config或web.config中检查您的版本。
3- 在硬盘驱动器上搜索程序集,在结果页面中选择每个文件,查看属性中的详细信息选项卡,并检查版本,以便找到不需要的版本来自何处。
4- 删除bin文件夹并重新构建。
也请检查this link

代码在Visual Studio中运行正常。有任何想法如何在Blue Prism中实现吗? - robt

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的程序集。然后您可以引用最新版本。

代码在Visual Studio中可以正常工作。有任何想法如何在BluePrism中实现吗? - robt

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>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接