简体   繁体   English

.NET 4.7.1上HttpClientHandler.SslProtocol的PlatformNotSupportedException

[英]PlatformNotSupportedException for HttpClientHandler.SslProtocol on .NET 4.7.1

I have following code in .NET Framework 4.7.1: 我在.NET Framework 4.7.1中有以下代码:

using (var handler = new HttpClientHandler())
{
    handler.SslProtocols = SslProtocols.Tls12;

    ...
}

This code works on my development machine (Windows 10 Enterprise, Build 17101/rs4_release. 180211-1040; Version 1803; OS Build 17101.1000). 该代码可在我的开发机器上运行(Windows 10 Enterprise,Build 17101 / rs4_release。180211-1040;版本1803; OS Build 17101.1000)。

The same code (when published to service fabric cluster nodes which already have .net framework 4.7.1 installed) causes following exception: 相同的代码(发布到已安装.net Framework 4.7.1的服务矩阵群集节点时)导致以下异常:

System.PlatformNotSupportedException: Operation is not supported on this platform.

The cluster nodes are running Windows Server 2012 R2 Data Center, Version 6.3 (Build 9600) 群集节点正在运行Windows Server 2012 R2数据中心版本6.3(内部版本9600)

When the code is decompiled using Resharper, my desktop shows the following information: 使用Resharper对代码进行反编译时,我的桌面显示以下信息:

// Type: System.Net.Http.HttpClientHandler
// Assembly: System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// MVID: 7D453494-012A-4FA4-9E04-1C64E3A0FB6F
// Assembly location: C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Net.Http\\v4.0_4.0.0.0__b03f5f7f11d50a3a\\System.Net.Http.dll

and it shows following on the another local server machine: 并且在另一台本地服务器上显示以下内容:

// Type: System.Net.Http.HttpClientHandler
// Assembly: System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// MVID: 641F4770-704A-420A-A419-A4FAF4195ADD
// Assembly location: C:\Windows\Microsoft.NET\Framework\\v4.0.30319\\System.Net.Http.dll

As you can see the assembly locations are different, but I don't know what this means. 如您所见,装配位置不同,但是我不知道这意味着什么。 In addition, my local machine has this value for registry key: 另外,我的本地计算机的注册表项具有以下值:

"Software\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full\\Release": "461802"

and cluster node has this: 群集节点具有以下功能:

"Software\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full\\Release": "461310"

The documentation on how to determine the installed framework version says: 有关如何确定已安装框架版本文档说:

On all other OS versions: 461310

but the version "461802" from my machine is not even listed there! 但是我的机器上没有列出版本“ 461802”!

Can someone please provide guidance on how to get past this error (without changing my code)? 有人可以提供有关如何克服此错误的指导(无需更改我的代码)吗?

While you shouldn't have posted the issue in the dotnet/announcement repo I'm not sure why people downvote your question here; 虽然您不应该在dotnet / announcement repo中发布该问题,但我不确定为什么人们会在这里否决您的问题。 it's a legitimate issue. 这是一个合法的问题。

The property HttpClientHandler.SslProtocols was added in .NET Framework 4.7.1 but wasn't actually implemented (you can call this a bug). HttpClientHandler.SslProtocols属性是在.NET Framework 4.7.1中添加的,但实际上并未实现(您可以将其称为错误)。

This is fixed with .NET Framework 4.7.2, which is probably the reason it works on your development machine. .NET Framework 4.7.2已修复此问题,这可能是它在开发计算机上工作的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM