Troubleshooting "program does not contain a static 'Main' method" when it clearly does...?
My MS Visual C# program was compiling and running just fine. I close MS Visual C# to go off and do other things in life.
I reopen it and (before doing anything else) go to "Publish" my program and get the following error message:
Program C:\myprogram.exe does not contain a static 'Main' method suitable for an entry point
Huh? Yes it does... and it was all working 15 min earlier. Sure, I can believe that I accidentally hit something or done something before I closed it up... but what? How do I troubleshoot this?
My Program.cs file looks like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Threading;
namespace SimpleAIMLEditor
{
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new mainSAEForm());
}
}
}
...and there are some comments in there. There are no other errors.
Help?
Are the properties on the file set to Compile?
I was struggle with this error just because one of my class library
projects was set acceddentaly
to be an console application
so make sure your class library projects is class library in Output type
Oke, I was looking at this issue as well. And in my case the solutions was too easy. I added a new empty project to the solution. The newly added project is automatically set as a console application. But since the project added was a 'empty' project, no Program.cs existed in that new project. (As expected)
All I needed to do was change the output type of the project properties to Class library
If you have a WPF or Silverlight application, make sure that App.xaml has "ApplicationDefinition" as the BuildAction on the File Properties.
I had this error and solved by this solution.
--> Right click on the project
--> and select "Properties"
--> then set "Output Type" to "Class Library".