Using System.Windows.Forms classes in a .net core 3.0 preview9 project

别等时光非礼了梦想. 提交于 2019-12-22 05:23:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!