asp.net mvc - Autofac not working after update -
i have updated autofac.mvc version 3.2.1 3.3.0, updated other packages including ef, mvc, webactivatorex etc , after update giving error on controller
no parameterless constructor defined object
i put breakpoint in initialization class , found not hitting breakpoint. i've separate dependency resolution layer in project , code initialization class
[assembly: webactivatorex.preapplicationstartmethod(typeof(iocconfig), "registerdependencies")] namespace myapp.bootstrapper { public class iocconfig { public static void registerdependencies() { var builder = new containerbuilder(); const string nameorconnectionstring = "name=appcontext"; builder.registercontrollers(typeof(mvcapplication).assembly); builder.registermodule<autofacwebtypesmodule>(); builder.registergeneric(typeof(entityrepository<>)).as(typeof(irepository<>)).instanceperhttprequest(); builder.registergeneric(typeof(service<>)).as(typeof(iservice<>)).instanceperhttprequest(); builder.registertype(typeof(unitofwork)).as(typeof(iunitofwork)).instanceperhttprequest(); builder.register<ientitiescontext>(b => { var logger = b.resolve<ilogger>(); var context = new aspnetidentitywithonioncontext(nameorconnectionstring, logger); return context; }).instanceperhttprequest(); builder.register(b => nloglogger.instance).singleinstance(); builder.registermodule(new identitymodule()); var container = builder.build(); dependencyresolver.setresolver(new autofacdependencyresolver(container)); } } }
please guide me this.
the bootstrapper project bin dlls must loaded web project dll ,so in bootstrapper project >> select properties >> select build tab >> change output path >> web project bin (ex:..\myapp.web\bin)
Comments
Post a Comment