• Register
0 votes

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.


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.


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.


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;


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

1 vote
2 answers 22 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 593 views
Problem : I am trying to learn Java, I am very newbie however I wanted to know what I do to get the "run" it. I am facing below error: Static Error: This class does not have a static void main method accepting String[]. Below is my code: public class MyCaneirinho { public static void mycontar ... { System.out.println(j + x + y); } else { System.out.println(j + x + y + z); } } } } // MyCarneirinho
asked Dec 10, 2019 alecxe 7.5k points
0 votes
3 answers 551 views
Problem : Why is the below error occurring? An object reference is required for the nonstatic field, method, or property 'WindowsApplication1.Form1.setTextboxText(int)
asked Jan 18, 2020 jwilliam 3.9k points
1 vote
1 answer 26 views
Problem: I wrote the following subclass for my main program: #include <stdio.h> #include <stdlib.h> #include "function.h" #define READFILE "r" #define WRITEFILE "w" #define WORDARRAYSIZE 16 #define MAXIMUMWORDCHARACTERS 15 void CreateWordList (char inputFileName [ ... completely useless in its remedial stages, but somewhere, the following error occurs, &ldquo;Undefined reference to main c++&rdquo;
asked Mar 9, 2020 Gavin 15.3k points
0 votes
2 answers 275 views
Problem : I got bellow message from my code Exception in thread "main" java.lang.ArithmeticException: / by zero
asked Nov 1, 2019 peterlaw 6.9k points
0 votes
1 answer 521 views
Problem : In my code have main method in it. The program compiles on jgrasp with no errors but it keeps giving me a message as bellow: "no main methods, applets, or Midlets found in file jgrasp"
asked Nov 1, 2019 peterlaw 6.9k points
0 votes
1 answer 5 views
Is there anything I need to do?
asked Dec 30, 2020 TeamScript 9.3k points
0 votes
1 answer 9 views
How can I resolve this error?
asked Dec 28, 2020 TeamScript 9.3k points
2 votes
1 answer 20 views
Problem: Let me thanks to all Kodlogs users first. I found this website very helpful over the internet. I found all the users and their behavior and solutions very helpful. Anyway, I am trying to learn java and I write my very first java program. Unfortunately, my ... using eclipse java as my IDE. Don&rsquo;t know is it the problem of my coding or the IDE. Any legitimate solution is appreciated.
asked Mar 29, 2020 Gavin 15.3k points
0 votes
1 answer 33 views
I was working on that but I got into some problems.
asked Nov 6, 2020 TeamScript 9.3k points