修改项目的csproj文件
<PropertyGroup> <OutputType>WinExe</OutputType> <TargetFramework>net6.0-windows</TargetFramework> <Nullable>enable</Nullable> <UseWPF>true</UseWPF> <UseWindowsForms>true</UseWindowsForms> </PropertyGroup>
添加<UseWindowsForms>true</UseWindowsForms>
标签:Windows,System,Forms,引用,WPF,true From: https://www.cnblogs.com/yzhyingcool/p/17856676.html