Aspen
Aspen

Reputation: 143

Does not contain a static 'Main' [BUT IT DOES?]

I'm following quill18creates C# tutorial series on youtube. I'm on video #3, where we start discussing classes and the main.cs script to execute code.

I've copied his example verbatum and started the project EXACTLY as he did in xamarin studio but no matter what, the compiler does not seem to want to accept the code.

Code:

using System; // We need the standard .NET library for many things

namespace DodgeGame
{
    class DodgeGameMain
    {
        static void Main()
        {

        }
    }

}

C:\Users\Aspen\Documents\Projects\DodgeGameSolution\DodgeGame\CSC: Error CS5001: Program does not contain a static 'Main' method suitable for an entry point (CS5001) (DodgeGame)

I've noticed that his Xamarin Studio is detecting a "document outline" while mine just says "an outline is not available for the current document". I've tried to save as. the file but that didn't change a thing. So what's going on?

You'll notice from this pic it's not displaying the class in green either:

enter image description here

Upvotes: 2

Views: 1197

Answers (2)

Aspen
Aspen

Reputation: 143

OKAY! So props to Victor Leontyev for suggesting to make a clean solution.

I exited, deleted the project. Remade it and this time upon creating the empty file, I checked "add to project" this time. It was off by default for some reason and wasn't even an option at the time the tutorial was made.

This solved all the problems and copy/pasting the code back in seemed to find the classes and compile correctly. A very simple oversite that caused so many problems. Doh'

Upvotes: 1

Umang Jaiswal
Umang Jaiswal

Reputation: 41

Change the Output Type under the Project > Properties to that of a “Class Library”. By default, this setting may have been set to a “Console Application”.

Upvotes: 3

Related Questions