加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – 命中错误:在解析器和自定义注册提供程序中找到

发布时间:2020-12-16 04:06:09 所属栏目:asp.Net 来源:网络整理
导读:我们在某些环境中遇到以下错误,似乎是在应用程序池回收之后. 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. 我们
我们在某些环境中遇到以下错误,似乎是在应用程序池回收之后.

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注册我们的控制器工厂,只有this blog中指出的IDependencyResolver

我们使用Castle Windsor(看似无关)作为我们的容器,在Global.asax的Application_Start中,首先注册所有依赖项并调用以下内容来注册IDepencencyResolver.

DependencyResolver.SetResolver(new WindsorDependencyResolver(IoC));

可能导致此异常的原因是什么?任何帮助,将不胜感激.

解决方法

不推荐在Castle Windsor中使用MVC DependencyResolver,因为它有一个设计缺陷:它不会在应该发布服务实例时释放它.有关完整说明,请参阅此 article.

相反,使用Windsor documentation中说明的方法,该方法使用自定义工厂将依赖项注入控制器.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读