WebHostBuilder.Build () MissingMethodException in .NET Core migrated solution

I am migrating a solution built using the .NET Core SDK 1.0.0-preview2-1-003177 because I want to use it in Visual Studio 2017. I am using the dotnet migrate command from the .NET Core SDK 1.0.1, it is going well. it compiles. When I run the web part with IIS Express, the classic Program.cs containing

var host = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup<Startup>() .Build(); host.Run(); 

Build () crashes with this exception

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

I can not find the reason at all.

+7
c # .net-core dotnet-cli
source share
2 answers

It looks like some of your dependencies are not updated to the correct version. This may be an old version or a new version. You can create a new project (dotnet new) and check the package version in the csproj file. 99% of the error causes version mismatch.

+5
source share

This happened to me because I was too impatient and installed too many EntityFrameworkCore packages.

I had

 Microsoft.EntityFrameworkCore 2.0.0-preview1-final Microsoft.EntityFrameworkCore.SqlServer 1.1.2 

I deleted the first, so I stayed with

 Microsoft.EntityFrameworkCore.SqlServer 1.1.2 

And then the error disappeared.

+1
source share

All Articles