How to fix Visual Studio 2022 Warning CA1416 “Call site reachable by all platforms” but “only supported on: ‘windows'”?

I had success removing the CA1416 warnings by adding the following decorator to the top of the containing class:

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

I’m only on VS2019 and using .net 5, but it may work for you. I tried this with VS2019 .net5 console project (top of class Program) and a .net5 class library (top of the class).
I added the System.Common.Drawing nuget package.
My code included:

string inputPath = @"C:\mypath\mypng.png";
Image i = Image.FromFile(inputPath);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)