asp.net-mvc - 点击错误: An instance of IControllerFactory was found in the resolver as well as a custom registered provider

标签 asp.net-mvc asp.net-mvc-3 exception castle-windsor ioc-container

我们在某些环境中遇到了以下错误,似乎是在应用程序池回收之后。

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/

相关文章:

javascript - 如何追加部分 View 的根元素

c# - 有没有一种方法可以在任一字段发生更改时触发远程验证属性?

c# - Facebook 登录会永久重新加载页面

javascript - VS2008 的 onerror 处理

asp.net-mvc - MVC 3 临时数据容器的缺点

asp.net-mvc - ASP.NET Web API 中没有区域的多级路由

javascript - jquery Accordion 内的表

c# - 一页多表单 (MVC3)

exception - CSipSimple 抛出异常 JNI 在应用程序中检测到错误,输入无效修改后的 UTF-8 : illegal start byte 0x8e

c# - 通过 WCF Web 服务将数据设置到 ADO 数据库