I am trying to add control to a Winforms application running on .NET Core 6.0 in VS 2022 Community edition. Whenever I add a control from the toolbox, like a button or a label, and try to save the project, an error message pops up
Should have two or more class parts
There's no further information. Here's a screenshot or reference:

Any ideas?
In my case, the problem seems to be adding a second class in the form class file.
Workaround: Define the new class in another file.
Steps to reproduce the issue [Visual Studio 17.5.0 final]:
Windows Forms App (C#). Next.
Set project name (i.e. MyApplication). Next.
Framework: .NET 6.0 (Long Term Support). Create.namespace MyApplication
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
public class MyClass
{
public string Name { get; set; }
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With