简体   繁体   English

net5.0-windows:警告 CA1416:“windows”支持“RegistryValueKind.DWord”

[英]net5.0-windows: warning CA1416: 'RegistryValueKind.DWord' is supported on 'windows'

The target framework of my project is set to net5.0-windows .我项目的目标框架设置为net5.0-windows

A C# file contains a call to Microsoft.Win32.Registry.SetValue() which gives me the following warning: C# 文件包含对Microsoft.Win32.Registry.SetValue()的调用,这给了我以下警告:

warning CA1416: 'Registry.SetValue(string, string?, object, RegistryValueKind)' is supported on 'windows'

Why do I get this warning if my project is set to net5.0-windows ?如果我的项目设置为net5.0-windows ,为什么会收到此警告?

Update: What is the proper way to handle error CA1416 for .NET core builds?更新: 为 .NET 核心构建处理错误 CA1416 的正确方法是什么? as pointed out by pavel-anikhouski does not fix the problem.正如pavel-anikhouski 所指出的那样并不能解决问题。

My issue arises because I use a shared AssemblyInfo.cs file in my project and have <GenerateAssemblyInfo> set to false .出现我的问题是因为我在项目中使用了共享的 AssemblyInfo.cs 文件并将<GenerateAssemblyInfo>设置为false

Adding the following line to AssemblyInfo.cs fixes the issue:将以下行添加到 AssemblyInfo.cs 可解决此问题:

[assembly: System.Runtime.Versioning.SupportedOSPlatform("windows")]

The issue and workaround at GitHub: https://github.com/dotnet/sdk/issues/14502 GitHub 的问题和解决方法: https://github.com/dotnet/sdk/issues/14502

暂无
暂无

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

相关问题 如何修复 Visual Studio 2022 警告 CA1416“所有平台均可访问的呼叫站点”但“仅支持:‘windows’”? - How to fix Visual Studio 2022 Warning CA1416 "Call site reachable by all platforms" but "only supported on: 'windows'"? CA1416 此呼叫站点可在所有平台上访问。 'Image.FromStream(Stream)' 仅支持:'windows' - CA1416 This call site is reachable on all platforms. 'Image.FromStream(Stream)' is only supported on: 'windows' 如何修复 vscode 中的 C# 警告 CA1416? - How to fix C# Warning CA1416 in vscode? MSTest v2 不能与 net5.0-windows 一起运行 - MSTest v2 won't run with net5.0-windows 修复错误(?)警告 CA1416:此呼叫站点可在所有平台上访问 - Fix false(?) warning CA1416: This call site is reachable on all platforms 为 .NET 核心构建处理错误 CA1416 的正确方法是什么? - What is the proper way to handle error CA1416 for .NET core builds? 仅在 Windows 上:net5.0-windows(或 net6.0-windows)是否允许我在 .Net 5(或 .Net 6)中重新编译 .Net 框架? - On Windows only: does net5.0-windows (or net6.0-windows) allow me to recompile .Net framework in .Net 5 ( or .Net 6)? 有没有办法让 VSC 的 c# 插件在 ubuntu linux 上用于目标 net5.0-windows 的项目? - Is there a way to get the c# plugin for VSC to work on ubuntu linux for a project with target net5.0-windows? CA1416。 如何告诉 builder 唯一的平台是 Windows? - CA1416. How to tell builder that only platform is Windows? .NET 5.0 中的 Windows 媒体播放器 - Windows Media Player in .NET 5.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM