问题
How can we use classes like Screen in a .NET Core 3.0 WPF project? There are documentation pages for .NET Core 3.0 for them, so I assumed it should work.
VS and the compiler tell me that the namespace Forms
does not exist in System.Windows
, so it feels like the classes are not in the 3.0 sdk.
There is no System.Windows.Forms
package on nuget, and the "Add reference" dialog has only a System_Windows_Forms
reference to the .net framework available, which sounds horribly wrong:
Am I missing something?
回答1:
You should add <UseWindowsForms>true</UseWindowsForms>
in your csproj.
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<UseWpf>true</UseWpf>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
来源:https://stackoverflow.com/questions/57908184/using-system-windows-forms-classes-in-a-net-core-3-0-preview9-project