I am trying to understand how to configure StructureMap for ASP.NET MVC3. I already use NuGet and notice that it creates an App_Start folder with a cs file called StructuremapMVC, so I check it and notice that it is the same code, but simplified, which will be written manually in the App_Start section hosted on Global.asax. ..
This is my IoC class code.
public static class IoC { public static IContainer Initialize() { ObjectFactory.Initialize(x => { x.Scan(scan => { scan.TheCallingAssembly(); scan.WithDefaultConventions(); scan.AddAllTypesOf<IController>(); }); x.For<OpcionDB>().Use(() => new DatabaseFactory().Get()); }); return ObjectFactory.Container; } }
My question is: why do I get an exception when I add some IoC on my controllers as the following (I use this template: Entity Framework 4 CTP 4 / CTP 5 General repository template and Unit Testable ):
private readonly IAsambleaRepository _aRep; private readonly IUnitOfWork _uOw; public AsambleaController(IAsambleaRepository aRep, IUnitOfWork uOw) { _aRep = aRep; this._uOw = uOw; } public ActionResult List(string period) { var rs = _aRep.ByPeriodo(period).ToList<Asamblea>(); return View(); }
An exception:
Exception Details: System.MissingMethodException: No parameterless constructor defined for this object.
asp.net-mvc asp.net-mvc-3 entity-framework structuremap code-first
Angel Escobedo Mar 16 2018-11-11T00: 00Z
source share