I work with legacy code and try to implement DI pattern in asp.net web service (asmx files) using ninject, but i don`t know where and how to initialize service-locator, that will track dependencies.
Any examples and advices will be usefull, thanks
I work with legacy code and try to implement DI pattern in asp.net web service (asmx files) using ninject, but i don`t know where and how to initialize service-locator, that will track dependencies.
Any examples and advices will be usefull, thanks
There's a ninject module for asp.net webforms. Instructions on setting it up are here. After that, all you have to do is specify how to resolve you're dependencies and then add an [Inject]able property for each dependency you want injected in you're asmx.cs file
This is an old question, but since I was taken here first by a search engine I thought I would add a pointer to another question with the answer:
The gyst of it is that your web service needs to inherit from Ninject.Web.WebServiceBase instead of System.Web.Services.WebService
Then you can inject into it using the [Inject] annotation.