[英]How to fix Visual Studio 2022 Warning CA1416 "Call site reachable by all platforms" but "only supported on: 'windows'"?
[英]net5.0-windows: warning CA1416: 'RegistryValueKind.DWord' is supported on 'windows'
我项目的目标框架设置为net5.0-windows
。
C# 文件包含对Microsoft.Win32.Registry.SetValue()
的调用,这给了我以下警告:
warning CA1416: 'Registry.SetValue(string, string?, object, RegistryValueKind)' is supported on 'windows'
如果我的项目设置为net5.0-windows
,为什么会收到此警告?
更新: 为 .NET 核心构建处理错误 CA1416 的正确方法是什么? 正如pavel-anikhouski 所指出的那样并不能解决问题。
出现我的问题是因为我在项目中使用了共享的 AssemblyInfo.cs 文件并将<GenerateAssemblyInfo>
设置为false
。
将以下行添加到 AssemblyInfo.cs 可解决此问题:
[assembly: System.Runtime.Versioning.SupportedOSPlatform("windows")]
GitHub 的问题和解决方法: https://github.com/dotnet/sdk/issues/14502
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.