ISErviceProvider in asp.net core library project

22 views
Skip to first unread message

Fabricio Martínez Tamayo

unread,
Mar 28, 2017, 8:04:16 PM3/28/17
to Autofac
Hello, 

I'm trying to understand how to get and IServiceProvider where before I could just do DependencyResolver.Current.GetService() and do not find any help in the docs.

How can this be done un a asp.net core library project?

Thanks.

P.S. The services are registered in a asp.net core web app. But I want to control execution using command query responsibility segregation pattern that I have defined in a separate asp.net core library project.
.

Fabricio Martínez Tamayo

unread,
Mar 29, 2017, 4:53:32 AM3/29/17
to Autofac
Well the simplest solution is passing the IServiceProvider to the library through the constructer during object creation. Too bad there is no DependencyResolver.Current.GetService()

Travis Illig

unread,
Mar 29, 2017, 12:35:08 PM3/29/17
to Autofac
I think you're looking for RequestServices.

Since this is an ASP.NET Core question (ie not Autofac) I'd recommend checking out the ASP.NET Core docs on DI. Tgey address your specific question.

https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection

Reply all
Reply to author
Forward
0 new messages