很简单,打开 .csproj
项目文件:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
</Project>
将net8.0修改为net8.0-windows,同时开启Forms设置 <UseWindowsForms>true</UseWindowsForms>
即可。