I need to add Windows Hello to my C# .NET 8 WinForms project. I found a solution here for .Net Framework, but I am using .NET 8. When I try this solution anyways, I get the following error:
NETSDK1135: SupportedOSPlatformVersion 10.0.26100.0 cannot be higher than TargetPlatformVersion 7.0.
I installed the latest version of this package as per the solution linked above, and notice the version number:
Adding:
<PropertyGroup>
<TargetPlatformVersion>10.0.26100.0</TargetPlatformVersion>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
to the .csproj file just results in more errors:
As suggested in the link in the error, when I add:
<TargetFramework>net8.0-windows10.0.26100.0</TargetFramework>
I get the error:
10.0.26100.0 is not a valid TargetPlatformVersion for Windows. Valid versions include:
10.0.22621.0
10.0.22000.0
10.0.20348.0
10.0.19041.0
10.0.18362.0
10.0.17763.0
10.0.22000.0
10.0.20348.0
10.0.19041.0
10.0.18362.0
10.0.17763.0
8.0
7.0
I tried playing around with different numbers, but I am still having trouble getting it to work.
I installed the 10.0.26100.0 SDK here.
I found the solution here. The problem is that Visual Studio has not been updated to include 10.0.26100.1. You can add it manually by adding this to the .csproj file:
<ItemGroup>
<WindowsSdkSupportedTargetPlatformVersion Include="10.0.26100.1" WindowsSdkPackageVersion="10.0.26100.1" MinimumNETVersion="6.0" />
<SdkSupportedTargetPlatformVersion Include="10.0.26100.1" />
</ItemGroup>
Here is what my .csproj file looks like now:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<TargetFramework>net8.0-windows10.0.26100.1</TargetFramework>
<TargetPlatformVersion>10.0.22621.1</TargetPlatformVersion>
</PropertyGroup>
<ItemGroup>
<WindowsSdkSupportedTargetPlatformVersion Include="10.0.26100.1" WindowsSdkPackageVersion="10.0.26100.1" MinimumNETVersion="6.0" />
<SdkSupportedTargetPlatformVersion Include="10.0.26100.1" />
</ItemGroup>
</Project>
I also had to uninstall the NuGet packages. Also, make sure to clean your solution in Build > Clean Solution and Build > Clean [project name]
I am guessing Visual Studio will fix this in a future update.