gpt4 book ai didi

exception - 无法加载文件或程序集System.Net.Http.Primitives。找到的程序集的 list 定义与程序集引用不匹配

转载 作者:行者123 更新时间:2023-12-03 05:32:18 25 4
gpt4 key购买 nike

我正在开发一个使用 Google API 的程序。但是,每次运行程序时,我都会收到以下错误:

Could not load file or assembly 'System.Net.Http.Primitives, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f711d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.

我正在使用 Visual Studio 2012 Express。我尝试遵循此link浏览了很多论坛,但似乎都不起作用。主要问题似乎来 self 引用的DLL文件“Google.Apis.dll”,它引用了System.Net.Http.Primitives v1.5.0.0。但是我的程序引用的版本是2.2.13.0。我尝试使用程序引用 v1.5.0.0(我设法找到 dll 以及 Google.Apis 的源代码),但这只会导致另一个问题,我需要更新版本的 System.Net。 Http.Primitives。

我一直在尝试找到一种方法来解决这个问题,但是我似乎找不到任何有效的方法。感谢您抽出时间。

最佳答案

我在使用 Google API 时遇到了同样的问题。这里的主要问题是,如果您安装Microsoft Http Client Libraries,它会将 System.Net.Http.Primitives DLL 的更新版本放入您的项目中。 web.config 假设您仍在使用默认版本 1.5。需要做两件事来修复它:

第一:更新到最新版本的 Google APIMicrosoft Http 客户端库。您可以通过 NuGet 安装更新。右键单击您的网站,单击“管理 NuGet 包”,选择左侧的更新。在撰写本文时,某些 Google API 还只是预发布版本。您可以通过 NuGet 选择更新屏幕左上角的“包括预发行版”来安装它们。

第二更新/添加一个 dependentAssembly 到您的 web.config 中。为此,您需要知道已安装的 System.Net.HTTP.Primitives.dll 的版本。查看 Windows 资源管理器中的 bin 目录。找到System.Net.HTTP.Primitives.dll,右键单击它,选择属性,然后单击“详细信息”选项卡。请注意那里的版本。在发表这篇文章时,我的版本是 4.0.10.0

然后添加/更新 dependentAssembly 部分以获取正确的版本。

<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>

关于exception - 无法加载文件或程序集System.Net.Http.Primitives。找到的程序集的 list 定义与程序集引用不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18370360/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com