无法加载文件或程序集 System.Net.Http.Primitives.定位程序集的清单定义与程序集引用不匹配 [英] Could not load file or assembly System.Net.Http.Primitives. Located assembly's manifest definition does not match the assembly reference

查看:27
本文介绍了无法加载文件或程序集 System.Net.Http.Primitives.定位程序集的清单定义与程序集引用不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm working on a program that uses the Google API. However every time I run my program, it I keeps getting the following error:

无法加载文件或程序集System.Net.Http.Primitives, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f711d50a3a"或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.

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 并查看了很多论坛,但似乎没有一个工作.主要问题似乎来自我引用的 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.

I'm using Visual Studio 2012 express. I've tried following this link and looked through many forums, but none seem to work. The main problem seems to come from the DLL file "Google.Apis.dll" which I referenced, and it references System.Net.Http.Primitives v1.5.0.0. However the version my program references is 2.2.13.0. I've tried having the program reference v1.5.0.0 instead (I manage to find the dll along with the source code of Google.Apis) however this only caused another problem in which I needed a more recent version of System.Net.Http.Primitives.

我一直在尝试找到解决此问题的方法,但是我似乎找不到任何可行的方法.谢谢你的时间.

I'm been trying find a way to work around this, however I can't seem to find anything that works. Thank you for time.

推荐答案

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

I ran into the same issue with the Google API's. The main issue here is if you install the Microsoft Http Client Libraries it puts in your project an updated version of the System.Net.Http.Primitives DLL. The web.config assumes you are still using the default version of 1.5. There are two things that need to happen to fix it:

首先:更新到最新版本的 Google APIMicrosoft Http 客户端库.您可以通过 NuGet 安装更新.右键单击您的网站,单击管理 NuGet 包",选择左侧的更新.在这篇文章的时候,一些谷歌 API 只是预发布的.您可以通过 NuGet 安装它们,方法是选择更新屏幕左上角的包括预发行版".

First: Update to the latest versions of Google API and Microsoft Http Client Libraries. You can install the updates via NuGet. Right click on your website, click "Manage NuGet Packages", select Updates on the left. At the time of this post some of the Google API's are prerelease only. You can install them via NuGet by selecting "include prerelease" on the top left of the update screen.

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

Second Update/add a dependentAssembly into your web.config. To do this you need to know the version of the System.Net.HTTP.Primitives.dll that was installed. Look in your bin directory within Windows Explorer. Find System.Net.HTTP.Primitives.dll, right click on it, select properties, and click the "Details" tab. Note the version located there. At the time of this post mine was 4.0.10.0.

然后为正确的版本添加/更新dependentAssembly 部分.

Then add/update a dependentAssembly section for the correct version.

<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>

这篇关于无法加载文件或程序集 System.Net.Http.Primitives.定位程序集的清单定义与程序集引用不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆