简体   繁体   中英

Error CS0017 "Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point." problem

I opened a new project right now, and I opened a new class there with a "Main" inside it. I already read whole over the internet about it and I already got that it happens because I have more than one "Main" method, but I read that when you choose inside the - Properties --> Startup object - your "Main" that you want to open it should be fixed.

The problem is that it doesn't show them at all. What am I suppose to do?

That's the Error:

CS0017 Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point.

My classes:

First -

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BeginnerProject
{
    internal class Program
    {
        static void Main(string[] args)
        {
            
        }
    }
}

Second -

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BeginnerProject
{
    internal class FakeCoin
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hi");
        }
    }
}

Third -

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BeginnerProject
{
    internal class WhyLikeThat
    {
        static void Main(string[] args)
        {
            
        }
    }
}

Properties:

https://i.stack.imgur.com/5wkYV.png

As described in the official documention , you just need to specify your entry point in your .csproj by using the <StartupObject> or the <MainEntryPoint> tag.

In your case you should be writting something like <StartupObject>BeginnerProject.FakeCoin</StartupObject> if you want the second class to be your entry point.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM