Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, June 16, 2016 12:02 PM
Hello,
I added yesterday a class and added some code from a website. Later on I want it to remove it from the solution so what I did is started VS and remove it from the solution. Since then I received this error when I want to start and test the Windows Form Application.
So what I did is Google around but I found nothing what results into the solution. I checked every form for in any case something that's looks like a Main. So what I found on the top in every form was:
public (form name)()
{
InitializeComponent();
}
I'm afraid that I've done something wrong, but I don't know what. So the title is what I see when the program itself is starting to build it. The error list says: Program does not contain a static 'Main' method suitable for an entry point. I see only a red cross. No error code. But the file is CSC, so what is that?
So I was hoping that someone could help me so that I could test/build the solution again. Thanks anyway!
Donovan
All replies (3)
Thursday, June 16, 2016 12:16 PM ✅Answered | 1 vote
Did you accidentally remove the entire program.cs file?
If you create a new Windows Forms application you will see that you should have a Program.cs file containing a static class called Program with a static method called Main (and a comment saying this is the main entry point for the application).
Saturday, June 25, 2016 4:58 AM ✅Answered
Hi Donovan_DD,
>>”So could I just copy and paste the code at a new window form witch I should add to the solution”
You could right click and add a new class named “Program.cs” and add below code in it to solve your problem. In the code, you should modify the parameter value of “Application.Run()” and make it as the first start form class.
Or, you could create a new clean windows form application and then copy it “Program.cs” file to your project. Then, modify the namespace and first start form according to your need.
namespace WindowsFormsApplication1
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new TheFirstStartForm());
}
}
}
Best Regards,
Albert Zhang
Wednesday, June 22, 2016 4:36 PM
Aah omg yes I've no Program.cs file. So could I just copy and paste the code at a new window form witch I should add to the solution?