dotnet / orleans

Cloud Native application framework for .NET
https://docs.microsoft.com/dotnet/orleans
MIT License
10.07k stars 2.03k forks source link

DI - BuildServiceProvider() - Method not found #3244

Closed larsfjerm closed 7 years ago

larsfjerm commented 7 years ago

Seems to be breaking change in Microsoft.Extensions.DependencyInjection v2.0.0 where the BuildServiceProvider method has changed its return type from IServiceProvider to ServiceProvider.

MethodNotFoundException is being thrown when I'm using a Startup class.

Related: https://github.com/aspnet/DependencyInjection/issues/550

attilah commented 7 years ago

We can fix it for 1.5.1.

It is caused by a breaking change in Asp.Net DI and we've to rebuild Orleans using the 2.0 version once it will be released.

But it will be a mandatory upgrade to every Orleans consumer then.

sergeybykov commented 7 years ago

We shouldn't change dependencies, especially those with a breaking change, in a patch release. So 2.0 is the vehicle to change this I think.

ReubenBond commented 7 years ago

Are we the only consumers of these Microsoft.Extensions.* pieces? It seems like they made this change without us being aware about it and there's no way we (as a library) can support versions pre- and post- change simultaneously.

attilah commented 7 years ago

I don't think so that we're the only users:

https://packages.nuget.org/v1/FeedService.svc/Packages?$filter=substringof(%27Microsoft.Extensions.DependencyInjection.Abstractions%27,%20Dependencies)%20eq%20true&$select=Id,Dependencies

That's the first 100 package which depends on DI Abstractions, but I think this breaking change is only for those who use their DI implementation...not for the abstraction

TsengSR commented 7 years ago

Can't the dependency injection be abstracted away in it's own package, which can be replaced w/o directly referencing from Orleans?

I mean instead of Orleans.Runtime depending on M.E.DI, it could only depend on IServiceProvider (it's an interface that existed in .NET Framework for a long time) and have the start-class and the DI stuff in external package?

So we could then reference it like

<PackageReference Include="Microsoft.Orleans.OrleansRuntime" Version="1.5.0" />
<PackageReference Include="Microsoft.Orleans.Orleans.DependencyInjection" Version="2.0.0" />

or 

<PackageReference Include="Microsoft.Orleans.Orleans.DependencyInjection" Version="1.1.1" />

Whereas the Microsoft.Orleans.Orleans.DependencyInjection package would contain everything required for bootstrapping Startup.cs and building of the container?

Within the runtime itself, there is no need for the M.E.DI package and IServiceProvider.GetService(Type type) should be enough, right?

attilah commented 7 years ago

I'm closing this, since we've talked about this and, because we need to provide a default implementation of DI fully configured for Orleans 1.x and Microsoft.Extensions.DependencyInjection 2.0+ we've to say that they're incompatible. For Orleans 2.0+ it will not be an issue.