如何在 Xamarin Android 应用程序 C# 中启用 TLS 1.2 支持

How to enable TLS 1.2 support in an Xamarin Android application C#

我正在开发 Xamarin 项目。在 C# 代码的帮助下,我需要为我的项目访问 azure API。它会产生以下错误 'Could not create a secure channel'。所以我使用下面的代码行

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

但是在添加该行之后,它也会抛出同样的错误。

但是当我从控制台应用程序编译相同的代码时,它会产生结果。我的代码或我的移动设备有问题吗?

请参阅 link 了解此问题。 https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/http-stack?tabs=macos

Windows:项目选项 > Android 选项,然后单击高级选项按钮。 Mac: Project Options > Build > Android Build settings 然后点击 General 选项卡。

这不是我的答案。评论区有人告诉我。参考那个