• Register
0 votes
777 views

Problem :

I am unable to figure out what is wrong with my code.

When I try to compile my code I get the below message:

“Program does not contain a static 'main' method suitable for an entry point”

7 5 2
3,870 points

Please log in or register to answer this question.

2 Answers

0 votes

Solution :

I just had this issue myself very recently.

I just created the winforms project, decided to just refactor my code and my project would now not contain a UI, so I simply deleted my Program.cs and winforms files only to get a same error you mentioned above.

So you either need to re add your static void main() method or go into your project properties and change your output type in your Application tab to the Class Library.

OR

I have also experienced this Error. I only changed a dropdown situated in Project properties/Application tab (Output type:). My original selected value was "Class Library" but I somehow changed it to "Windows Application" and found same error and now it is resolved.

OR

Now every C# program needs the entry point. By default, the new c# Windows Forms project includes the Program class in your Program.cs file.

OR

Now your project must be created as the empty project. So your output type shows as the Console Application. Change it to the Class library, and it should work for you too.

9 7 4
38,600 points
0 votes

The Main() method is the standard entry point to the execution for any C# program. Libraries and services do not require the Main method as an entry point, This would be required when your application is a console application or windows application.

What is Main()?

It is the configured name for the main method, If you don’t have this method in your application and you try to build your application, then you get the following error;

“Program does not contain a static ‘Main’ method suitable for an entry point.”

A valid list of Main signatures:

public static void Main() { }

public static int Main() { }

public static void Main(string[] args) { }

public static int Main(string[] args) { }

public static async Task Main() { }

public static async Task<int> Main() { }

public static async Task Main(string[] args) { }

public static async Task<int> Main(string[] args) { }

Why this error occurs?

When the user sets a visual studio project for Sitcore, then you need to set the output to the class Library. If it is set to windows application or console application, then the user has to change it to Class Library. Else you will get the error;

Solution:

You can solve this by the following method;

  • Go to the project.
  • Right-click on the project.
  • Choose properties
  • Then change the output type to the class library.

 

11 5 2
3,890 points

Related questions

0 votes
1 answer 2 views
2 views
Problem How to fix this error: entry point must be definedin c++
asked 3 days ago Subhendu 4.4k points
1 vote
2 answers 36 views
36 views
Problem: Hello Kodlogs, I hope all of you are doing well. Just now I&rsquo;ve installed MS Visual Studio to run a C++ program. I&rsquo;ve downloaded a C++ program from the internet and paste the code inside the VS console. The same program worked in Eclipse but it ... a main() function which I did already. I found this forum very active and helpful. Could you guys save my day? Thanks a lot.
asked Apr 21, 2020 Gavin 15.3k points
0 votes
1 answer 5 views
5 views
Problem: Why is the Java main method static? Is there a reason for this method to be static? Thanks in advance
asked Mar 8 ummesalma 25.2k points
1 vote
1 answer 4 views
4 views
Problem: How to fix this error : program does not contain a static main
asked Mar 31 MUHAMMAD MUNEEB 83k points
1 vote
1 answer 3 views
3 views
Problem: Can someone please help fix this uncaught error : public static void main meaning in java
asked Mar 31 MUHAMMAD MUNEEB 83k points
1 vote
1 answer 2 views
2 views
Problem: I am unable to find out the solution, Please solve it : public static void main string args
asked Mar 31 MUHAMMAD MUNEEB 83k points
1 vote
1 answer 3 views
3 views
Problem: Please help me to solve it out : public static void main(string args)
asked Mar 31 MUHAMMAD MUNEEB 83k points
1 vote
1 answer 2 views
2 views
Problem: Why I got the error : public static void main(string args) explain
asked Mar 31 MUHAMMAD MUNEEB 83k points
1 vote
1 answer 1 view
1 view
Problem: How can I deal with this problem : public static void main(string args) in java
asked Mar 31 MUHAMMAD MUNEEB 83k points
1 vote
1 answer 2 views
2 views
Problem: I need a help , How I can fix this : public static void main(string args) java
asked Mar 31 MUHAMMAD MUNEEB 83k points