Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# The Solution

Sandra Gury
Sandra Gury
6,911 Points

I got an error message saying :it does not contain a static `Main' But it does! Can you help me understand what's wrong?

The code:

class Program
{
    static void Main()
    {
        System.Console.WriteLine("I love learning C# at Treehouse!");
    }
}
Error message: 
treehouse:~/workspace$ mcs Practice.cs                                                                                                                                    
error CS5001: Program `Practice.exe' does not contain a static `Main' method suitable for an entry point                                                                  
Compilation failed: 1 error(s), 0 warnings

3 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Sandra Gury ! Your code looks fine and I tested it in a workspace without error, which begs the question why you're receiving that compilation error. Now this may sound silly, but can you please reconfirm that you've saved the file? If there is an orange dot on the tab, it means the file wasn't saved since it was last edited. This is the only way I can reproduce that error.

If you're saving the file and still getting this error, linking a snapshot to your workspace would be helpful. This will allow us to fork your workspace and have a look around.

Hope this helps! :sparkles:

I had the same problem and Jennifer nailed it. I had not saved the file.

the problem is not on your code. when you use the console to compile your C# program you should type in the following: mcs Practice.cs && mono Practice.exe