7

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)'.'
Daniel Rusnok
  • 449
  • 1
  • 7
  • 14

6 Answers6

6

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

Rik Clews
  • 61
  • 1
  • 3
5

If you use Microsoft.AspNet.OData, this error occurs from NuGet version 7.5.15 and above. Downgrading to 7.5.14 may resolve this issue.

AecorSoft
  • 414
  • 4
  • 10
3

For .NET Core 3.1, for some reason Visual Studio wasn't giving me the hint that I need to add using Microsoft.Extensions.DependencyInjection;. Manually adding that fixed it for me.

Neurion
  • 379
  • 6
  • 15
2

Downgrade package ApplicationInsights to version 1.1.2 from 2.0 solved

Daniel Rusnok
  • 449
  • 1
  • 7
  • 14
1

I had similar issue when using Sql nuget and upgrading that fixed the issue.

IDbContextFactory had to be changed to IDesignTimeDbContextFactory

h-rai
  • 3,636
  • 6
  • 52
  • 76
0

I also experienced this error with Microsoft.AspNet.OData version 7.5.17 and downgrading to 7.5.14 resolved this error.