SimpleInjector - 确保控制器具有无参数的公共构造函数

时间:2014-10-09 11:27:57

标签: model-view-controller controller simple-injector

我使用nuget simple injector mvc集成快速入门将简单的进样器v2.5.2及相关软件包安装到我的helloworld mvc项目中。它在我的本地快递IIS中工作正常。但在我将其上传到生产IIS服务器后,它会抛出异常

  [MissingMethodException: No parameterless constructor defined for this object.]

  ....

  Make sure that the controller has a parameterless public constructor

SimpleInjectorInitializer类代码段如下所示。

            var container = new Container();
            container.Register<IService, Service>();
            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
            container.Verify();
            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));

This stackoverflow post无法帮助我,已经调用了DependencyResolver.SetResolver。

如何解决?我的生产IIS是否遗漏了任何配置?

0 个答案:

没有答案