c# 3.0 - Dependency injection with Unity and ASP.NET MVC -


I am trying to use unity as my IoC container, which "works" a bit.

From Snip Global.asax:

Secure void Application_Start () {// ...) Left / Out of Settlement with Microsoft Unity Dependency Injection () dependency injection; } Private Zero Dependence Injection () {var Container = New Unity Container (); Container. Registration Type & lt; ITimeregEntities, TimeregEntities & gt; (). Configure & Lt; Injectmen & gt; () .ConfigureInjectionFor & lt; TimeregEntities & gt; (New injection signature) ();) Container. Registration Type & lt; Timestridge controller IHelloWorld, Timelargestring Controller. Marie Sheld World & gt; (); // ### The problem here ### Container Registration Type & lt; ITIMEregistreringerRepository, Timeline Respository & gt; (); // ### END- Problem ### var Factory = New Unity Controller Feature (Container); ControllerBuilder.Current.SetControllerFactory (factory); }

This dependency has been imposed on my 'timerising' - Controller:

  Public Class TimerStorageing Controller: BaseController {// // GET: / Timrostringer / Public ActionResult Index () {var Approved = Timeline Recognition.FidAPPROID (); ViewData.Model = Approved; ViewData ["HelloText"] = attribute See Return (); } // ### This work [dependency] public IHelloWorld attribute {get; Set; } // ### END- This works ### # # # # # # # # # # # # # # # # Problem # Set; } // ### END- Problem ### Public Interface IHelloWorld {string SayHello (); } Public class MyHelloWorld: IHelloWorld {public string SayHello (return) "Hello, world!"; The implementation for TimeregistreringerRepository is as follows:  
  Public class TimeregistreringerRepository: Repositories, ITimeregistreringerRepository {Public TimeregistrerenderRepository (ITimeregEntities Institutions): Base (entities)} {} Public IQueryable & lt; Timeregistreringer & gt; FindApproved () {Return _entities .FindAll & lt; Timeregistreringer & gt; (). Where (t = & gt; t. Godkendt == true); }} Public Interface ITimeregistreringerRepository: IRAPZetry {IQueryable & lt; Timestrising & gt; FindApproved (); } Public interface erupository {add zero & lt; T & gt; (TT) where T: IERTI accounts; } Public Sector Repository: Irapposary {Protected ITemrerent Areas; Public Repository Database (ITimeregEntities Institutions) {_entities = entities; } #Areizoproteel members public IQueryable & lt; T & gt; FindAll & lt; T & gt; () {Return _entities.FindAll & lt; T & gt; (); } Add Public Zero  

Now I get the error for:

The solution to dependency failed, type = "[hidden by me]. MCCWeb Controller .Timrgritterringer Controller ", name =" ". The exception is the message: The current build operation (build build key [hidden by me] .mcweb.controllers.TimeGreatringController, null] failed: The value of the property "Time Registry Repository" can not be solved. (Strategy Type BuildPlanStrategy, Index 3)

Now note that in the method dependency injection (), write the timeregistreringerRepository to do register the ITimeregistreringerRepository, and there Is there is an [dependency] attribute on that class-attribute, so I can not see what I'm missing? Another thing to notice is that I have an additional attribute called "attribute" Which I have registered with IHelloWorld and MyHelloWorld, and it works perfectly.

Thank you for your time reading this :-) Looking forward to your thoughts and suggestions!

My problem stemmed from somewhere in the code, but wrapped in several other exceptions, hence the problem address It was very difficult to apply. Explaining this context is not interesting in this context.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -