在 .net core 3.0 preview9 项目中使用 System.Windows.Forms 类
Using System.Windows.Forms classes in a .net core 3.0 preview9 project
我们如何在 .NET Core 3.0 WPF 项目中像 Screen 一样使用 类?有 .NET Core 3.0 的文档页面,所以我认为它应该可以工作。
VS 和编译器告诉我 System.Windows
中不存在命名空间 Forms
,所以感觉 类 不在 3.0 sdk 中。
nuget 上没有 System.Windows.Forms
包,"Add reference" 对话框只有一个 System_Windows_Forms
对可用的 .net 框架的引用,这听起来非常错误:
我是不是漏掉了什么?
您应该在您的 csproj 中添加 <UseWindowsForms>true</UseWindowsForms>
。
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<UseWpf>true</UseWpf>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
我们如何在 .NET Core 3.0 WPF 项目中像 Screen 一样使用 类?有 .NET Core 3.0 的文档页面,所以我认为它应该可以工作。
VS 和编译器告诉我 System.Windows
中不存在命名空间 Forms
,所以感觉 类 不在 3.0 sdk 中。
nuget 上没有 System.Windows.Forms
包,"Add reference" 对话框只有一个 System_Windows_Forms
对可用的 .net 框架的引用,这听起来非常错误:
我是不是漏掉了什么?
您应该在您的 csproj 中添加 <UseWindowsForms>true</UseWindowsForms>
。
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<UseWpf>true</UseWpf>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>