Why does "ServiceCollection()" not exist in current context?

71 Views Asked by At

I am making a basic Discord Bot following a Blog i found online I am using Dotnet 8 on VS Code on a C# .Net Core Console App. I am a beginner what did i do wrong? Is the code deprecated?

Heres the Code Causing me Issues:

            var serviceProvider = new ServiceCollection()
                .AddSingleton<IConfiguration>(configuration)
                .AddScoped<IBot, Bot>()
                .BuildServiceProvider();

I tried searching online for alternatives and there werent any and yes i am using Microsoft.Extensions.DependancyInjection.

If needed i can provide more code but the problem is caused by ServiceCollection() simply not existing so i dont think that would be necessary.

Thanks

0

There are 0 best solutions below