D
D
dani220232022-01-11 12:25:29
C++ / C#
dani22023, 2022-01-11 12:25:29

How to fix error CS1555?

I can't fix error CS1555, what should I do?

public class Program
    {
        DiscordSocketClient client;

        public static void Main(string[] args)
            => new Program().MainAsync();

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vasily Bannikov, 2022-01-11
@dani22023

You have a crooked csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp5.0</TargetFramework>
    <StartupObject>Program</StartupObject>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Discord.Net" Version="3.1.0" />
    <PackageReference Include="Discord.Net.WebSocket" Version="3.1.0" />
  </ItemGroup>

</Project>

1. TargetFramework should be net5.0 (better - net6.0). TFM "netcoreapp5.0" does not exist
2. The StartupObject line is not needed. (just because of this, the error. The compiler is looking for a pubic static void Program method, which does not exist)

S
spaceatmoon, 2022-01-11
@spaceatmoon

the Main function should not call itself. This is complete nonsense. Write like this and you will be happy.

public class Program
{
        public static void Main(string[] args)
        {
        }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question