C# Compiler Error Message
Error CS0017 Program ‘output file name’ has more than one entry point defined. Compile with /main to specify the type that contains the entry point.
Reason for the Error
A program can only have one Main method. You will receive this error when there is more than one Main method in your program.
For example, take a look at the below code.
namespace ClassLibrary { public class Class1 { public static void Main() { } } public class Class2 { public static void Main() { } } }
The above .NET Console Application will result in the error when run in your .NET Console Application will result in the C# Compiler Error
Error CS0017 Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point. ConsoleApp1 C:\Users\Senthil\source\repos\ConsoleApp1\ConsoleApp1\Program.cs
Solution
To fix this error, you can remove all Main methods and retain only one of them. An other alternate option is to use the compiler option -main to specify which Main method to use in your .NET program.