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)
My problem is that I accidentally set the arguments for Main
static void Main(object value)
thanks to my refactoring tool. Took couple mins to figure out but should help someone along the way.
What I found is that the Program.cs file was not part of the solution. I did an add existing item and added the file (Program.cs) back to the solution.
This corrected the error: Error 1 Program '..... does not contain a static 'Main' method suitable for an entry point
I had this error and solved by this solution.
--> Right click on the project
--> and select "Properties"
--> then set "Output Type" to "Class Library".
What worked for me: Close MS Visual Studio, then start Visual Studio and open the solution. The error message was then gone.
I had this problem and its because I wasnt using the latest version of C# (C# 7.3 as of writing this) and I had to change the below internal
access modifier to public
.
internal class Program
{
public static void Main(string[] args)
{
//My Code
}
}
or ammend the .csproj
to use the latest version of C# (this way meant I could still keep the above class as internal
):
<PropertyGroup>
<LangVersion>latest</LangVersion>
<NoWin32Manifest>true</NoWin32Manifest>
</PropertyGroup>
It is important that the Main
method is placed in the class that is properly configured in Visual Studio as a start-up object:
SimpleAIMLEditor.Program
from the drop-down for your start-up objectNow run your application again. The error will disappear.