[英]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.