var builder = new ContainerBuilder(); builder.RegisterControllers(typeof(MvcApplication).Assembly); builder.RegisterAssemblyTypes(typeof(MvcApplication).Assembly).Where(x => x.Name.EndsWith("Repository")).AsImplementedInterfaces(); var container = builder.Build(); DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
这是原来在2012的可以用的代码,但是应用到2013版(昨天(发帖之时)新出的),运行时最后一句提示出错,生成时无提示错误。请教如何解决
改用了.Net Framework 4.5.1
自己解决,将autofac mvc4的引用改为autofac mvc5的,问题解决