Method not found: Microsoft.Extensions.DependencyInjection.IServiceCollection
From issue #8426, I ended up upgrading EFCore versions. I ran the following package manager commands in my web and DAL projects:
install-package Microsoft.EntityFrameworkCore.SqlServer -Pre -Version 2.0.0-preview1-final
install-package Microsoft.EntityFrameworkCore -Pre -Version 2.0.0-preview1-final
I then went to run my web application and got the following exception in the Program.cs file when it tries to execute
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
Method not found: 'System.IServiceProvider Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(Microsoft.Extensions.DependencyInjection.IServiceCollection)'.
I'm assuming the upgrade has broken something in my Startup class in my web app.
You need to upgrade all your packages from Asp.net core and not just the EF ones.
@ajcvickers i am getting this error very frequently, because of package dependencies. Project A references a package that uses v1 of package B. in other project some other package is using version 2 of B which results into this situation. and detecting which package is causing problem is some how impossible in large project. any idea?
I had this problem after I upgraded Microsoft.Extensions.DependencyInjection.Abstractions to version 2.0.0 then reverted back... Since the assembly is still on the hard drive it is still detected and loaded. The solution was to delete the bin folder and build a gain.
Ditto what @assilsicom said. I also reverted back to Core 1.1 from 2.0 and was getting this error. Deleting the bin folders worked as stated above and resolved the issue.
I have a .NET Standard 1.4 library that has Microsoft.EntityFrameworkCore.Sqlite 1.1.2 dependency There is a UWP project that references it and it works fine There is a .NET Core 2.0 project that references it and it gets this error
Please stop closing valid issues, this issue still exists
Reopening so that we can write a proper response here. Using 1.x & 2.x packages of Asp.net in same project is not supported.
running into same issue here, except I am using a service fabric stateless webapp, I read SF isn't compatible with AspNetCore 2.0 yet. Do i have to roll back because everything seems to be interdependent and a massive breaking change
I'm also running into this issue. The moment i hit "services.AddIdentityServer()" i'm getting the error.
Having the same issues as @JKeetman , Just updated to to .NET Core 2.0 and IdentityServer4-preview4
You need to update to ASP.NET Core 2.0. Anything that called BuildServiceProvider needs to be updated.
Same issue here. I've updated everything to 2.0. Also updated IdenetyServer 4 to 2.0.0-preview2. Any suggestions?
Same Error with ASP.NET Core 2.0 and IdenetyServer4 1.5.2
@gato-negro - IdentityServer4 1.5.2 uses ASP.NET core 1.1.x packages. 1.x to 2.0 is breaking change hence ASP.NET core 2.0 is not compatible with IdentityServer 1.5.2. You would need at least IdentityServer4 2.0.0-preview3 packages to use with ASP.NET Core 2.0
@smitpatel You are right. I updated all identityserver4 related packages to 2.0.0-rc1 and now it works as expected. Thanks
what if we have a library that Called BuildServiceProvider ? what Should replace it?
what if we have a library that Called BuildServiceProvider ? what Should replace it?
The library needs to be updated.
Ok, let's say I am the one responsible to do that, and I know where in my code base we are calling it, what would I need to change it to, to work now? Or where can I go that will help me figure that out? Because I'm almost positive that the library won't officially be updated anytime soon.
The library just needs to reference the new version of Microsoft.Extensions.DependencyInjection (the 2.0.0 version).
Ahh perfect, thank you
Just curious as to how the dependency tree is allowed to get into an incompatible scenario like this - is there something more that can be done via semver and nuspec versioning constraints on packages to prevent this kind of thing from happening?