.net - Constructor injection in MVC 3 -


itemprop = "text">

I have this code in my controller:

  public class IssueController: BaseController, IIssueController { #region Member IPublicationsManagementService Publishing Service; #Editional # Regional Producer Public Issuer Control (IPublicationsManagementService Publishing Service) {this.publicationService = publicationService; } #endregion public ActionResult IssueSearch () Return View (New IssueSearchViewModel () {magazine = new selectList (publicationService.GetAllProducts (), "Id", "name")}); }   

And web configuration has injection dependencies:

   & Lt; Manufacturer & gt; & Lt; Param name = "publication service" & gt; & Lt; Dependency name = "sd" /> & Lt; / Param & gt; & Lt; / Creator & gt; & Lt; Register type = "Infoquality.PSMS.Application.Publications.PublicationsManagement.IPublicationsManagementService, PSMS.Application.Publications" mapTo = "Infoquality.PSMS.Application.Publications.PublicationsManagement.PublicationsManagementService, PSMS.Application.Publications" name = "SD" & gt ; & Lt; Lifetime Type = "Singleton" /> & Lt; / Register & gt;   

When I run the application, the error occurs:

Source error:

generated during an ineffective exception The information about the origin and location of the current web request exception was found using the exception stack trace below.

Stack trace:

[MissingMethodException:. No parameterless manufacturer defined for this object] System System.RuntimeTypeHandle.CreateInstance (RuntimeType type, Boolean publicOnly, Boolean Nashech, Boolean and Canbach, RuntimeMhandle Initial and Citi, Boolean and BND Security Check) +0 / System Runtime type Create Instance Slow (Boolean Public Only, Boolean Skip Check, Boolean Filcap) +98 System Reintime type Createinstant Default Control (Boolean Publiconeili, Boolean skipVisibility Checks, Boolean skipCheckThis, Boolean fillCache) 241 System.Activator.CreateInstance (type type, Boolean nonpublic) +69
System.Web.Mvc.DefaultControllerActivator.Create (RequestContext requestContext, Type controllerType ) 67

I need ASP.NET MVC 3 and Razor engine to call the parametrized constructor.

You must implement the official reseller interface. Once you do this, you can use dependency injection anywhere within the MVC 3 application, even though the idea (though property injection only).

Comments