在 .Net Framework 中使用最新版本的 System.Net.Http [英] Use latest version of System.Net.Http in .Net Framework

查看:112
本文介绍了在 .Net Framework 中使用最新版本的 System.Net.Http的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最新版本

有关绑定重定向的一些信息 由 Microsoft 自己提供.

The latest version of System.Net.Http on nuget is 4.3.4. But even the latest .Net Framework 4.8 ships with 4.2.0 of this library.

Even if I add the nuget package Visual Studio 2019 still picks up the System.Net.Http.dll from the .Net Framework installation files.

Is there any way to get around this?

.Net Core still does not have designer support for wpf and winforms that's why i need this to work with .net framework.

解决方案

Totally agree with you that this is confusing, but at the end binding redirection is your friend here used with your app.config / web.config file.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

The above snippet forces whatever version comes in with your code that the version which is specified in "newVersion" attribute will be used.

The table below gives you some insights on the versioning differences.

Some info on the binding redirection by Microsoft itself.

这篇关于在 .Net Framework 中使用最新版本的 System.Net.Http的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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