我们在某些环境中遇到了以下错误,似乎是在应用程序池回收之后。
An instance of IControllerFactory was found in the resolver as well as a custom registered provider in ControllerBuilder.GetControllerFactory. Please set only one or the other.
我们没有使用 ControllerBuilder 来注册我们的 Controller 工厂,仅使用 IDependencyResolver,如 this blog 中指出的那样。
我们使用 CaSTLe Windsor(看似无关)作为容器,并在 Global.asax 的 Application_Start 中,首先注册所有依赖项并调用以下代码来注册 IDepencencyResolver。
DependencyResolver.SetResolver(new WindsorDependencyResolver(IoC));
什么可能导致此异常?任何帮助将不胜感激。
最佳答案
不建议将 MVC DependencyResolver 与 CaSTLe Windsor 一起使用,因为它存在设计缺陷:它不会在应该释放服务实例时释放服务实例。看这个article以获得完整的解释。
相反,请使用 Windsor documentation 中说明的方法它使用自定义工厂将依赖项注入(inject) Controller 。
关于asp.net-mvc - 点击错误: An instance of IControllerFactory was found in the resolver as well as a custom registered provider,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12514578/