How to introduce the Azure role?

I have an Azure Worker role that needs a repository. I usually use Ninject to inject these things into the constructor of the objects that I create, which works fine for MVC3 / 4 (I use it with Ninject.MVC).

However, it does not work with Azure worker roles. I need a constructor without parameters to run the role, so installing the constructor is not an option. I tried using DependencyResolver.Current.GetService to get my repository (from the constructor, from the OnStart() method and from the Run() method), but it returns null every time. I think this is because Application_Start() from MVC is not running yet? I dont know.

Can someone help me by explaining how I do this? Is anyone

+4
source share
1 answer

If you use the answer provided in this question You cannot inject dependencies for an Azure WorkerRole object using Spring.NET , you can work something, but then use Ninject instead of Spring.NET

+1
source

Source: https://habr.com/ru/post/1445370/


All Articles