从 .NET 5 开始,以下 API 标记为已过时。 使用这些 API 会在编译时生成警告 SYSLIB0009,并在运行时引发 PlatformNotSupportedException。
AuthenticationManager.Authenticate
AuthenticationManager.PreAuthenticate
解决方法
实现 IAuthenticationModule,其中具有先前由 AuthenticationManager.Authenticate 调用的方法。
禁止显示警告
建议尽可能使用可用的解决方法。 但是,如果无法更改代码,可以通过 #pragma 指令或 <NoWarn> 项目设置来禁止显示警告。 如果必须使用过时 API,并且 SYSLIB0XXX 诊断没有显示为错误,则可以在代码或项目文件中取消该警告。
若要禁止显示代码中的警告,请执行以下操作:
// Disable the warning.
#pragma warning disable SYSLIB0001
// Code that uses obsolete API.
//...
// Re-enable the warning.
#pragma warning restore SYSLIB0001
若要禁止显示项目文件中的警告,请执行以下操作:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<!-- NoWarn below suppresses SYSLIB0001 project-wide -->
<NoWarn>
本文系外文翻译,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文系外文翻译,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。