Dependency Injection with Microsoft.Extensions.DependencyInjection


My understanding from this discussion is that I won’t be able to use Constructor Injection in order to access dependencies injected with Microsoft.Extensions.DependencyInjection.

Is there a workaround that would allow me to access a single service injected into a service fabric application? While I could technically switch to Autofac, I’d like to avoid doing so. The application is part of a cluster of service fabric applications and will be maintained by many different people, and all the other applications on the cluster use Microsoft.Extensions.DependencyInjection.

(Hadi Eskandari) #2

Hi Simon,

If you want to share the same container between the ASP.NET Core pipeline and NServiceBus, the only way I can see so far is using the Autofac adaptor (the discussion you’re linking to). I understand it might not work for the scenario you mentioned.

We’re evaluating a better experience with .NET Core hosting and DI but at this point, I don’t have an ETA to give you.

(Daniel Marbach) #3

Hi Simon,

Your input would be appreciated

Thanks Daniel