无法加载文件或程序集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

查看:164
本文介绍了无法加载文件或程序集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,版本= 1.5.0.0,文化=中性,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。我尝试按照此链接进行浏览,论坛,但似乎无济于事。主要问题似乎来自我引用的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客户端库,它将在您的项目中添加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 API的最新版本 Microsoft Http客户端库。您可以通过NuGet安装更新。右键单击您的网站,单击管理NuGet软件包,然后选择左侧的更新。在本文发布时,某些Google API仅为预发布版本。您可以通过选择更新屏幕左上方的 include prerelease,通过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天全站免登陆