Method not found: 'System.IServiceProvider Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider'

Daniel Rusnok picture Daniel Rusnok · Jul 10, 2017 · Viewed 8k times · Source

In my Main method of .net Core app Iam getting this error and I dunno where should I look for solution.

this is my main method:

 public static void Main(string[] args)
    {
        var host = new WebHostBuilder()
            .UseKestrel()
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseIISIntegration()
            .UseStartup<Startup>()
            .UseApplicationInsights()
            .Build();

        host.Run();
    }

This is error message I am getting when hit F5 to fire project:

System.MissingMethodException: 'Method not found: 'System.IServiceProvider Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(Microsoft.Extensions.DependencyInjection.IServiceCollection)'.'

Answer

Rik Clews picture Rik Clews · Oct 10, 2017

I've just come across this issue using aspnet core 2.0, in my case upgrading the other default packages (AspNetCore, AspNetCore.Mvc, NetCore.App) to 2.0 did the trick, despite installing 2.0 the packages (apart from App insights) were 1.1.x initially