inversion of control - How configure LightInject in ASP.NET MVC? -


i use simpleinjector in mvc code

public static class simpleinjectorinitializer {     public static void initialize()     {         var container = new container();         initializecontainer(container);         container.registermvccontrollers(assembly.getexecutingassembly());         container.verify();         dependencyresolver.setresolver(new simpleinjectordependencyresolver(container));     }      private static void initializecontainer(container container)     {         container.register<ipersonrepository, personentityrepository>();     } } 

but want test lightinject ioc in mvc application how ?

i wrote code

[assembly: webactivator.postapplicationstartmethod(typeof(lightinjectinitializer), "initializeli")]  public static class lightinjectinitializer {     public static void initializeli()     {         var container = new servicecontainer();                     initializecontainer(container);         container.registercontrollers(assembly.getexecutingassembly());         container.enablemvc();     }      private static void initializecontainer(servicecontainer container)     {         container.register(typeof(personentityrepository), typeof(ipersonrepository), new perscopelifetime());      } } 

enter image description here

but show me error

no parameterless constructor defined object.  

can me writing equivalent code working in mvc ?

sample code : download

i author of lightinject , out.

this static initialize method? called from. reason error because initialize code did not execute.

if further assistance, valuable see have in global.asax.cs.

this page contains information how set up.

http://www.lightinject.net/#mvc


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -