对 .net7.0 类库项目中的 System.Windows.Forms 的引用

Reference to System.Windows.Forms in .net7.0 class library project

提问人:Eikey 提问时间:9/15/2023 最后编辑:Eikey 更新时间:10/7/2023 访问量:60

问:

我需要在用 .net7.0 编写的类库项目中添加对 System.Windows.Forms 的引用,该项目将在 NuGet 中为我的年轻学生分发。 这怎么能做到呢? 我要添加到项目中的类:

public class DebugApp
{
   Form form;
   TextBox textBox = new TextBox();
   Button button = new Button();
   Label label = new Label();
   Panel panel = new Panel();
   List<string> data = new List<string>();
   .....
}
C# Net-7.0 类库

评论

2赞 Hans Passant 9/15/2023
learn.microsoft.com/en-us/dotnet/core/project-sdk/......
0赞 Eikey 9/15/2023
我添加了那行,但它不起作用,也许缺少其他东西ץ

答:

-1赞 Eikey 10/7/2023 #1

我创建Windows窗体项目,将其更改为项目属性中的类库,删除Form1和Program.cs,它正在工作。