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.