简体   繁体   中英

Hitting error: An instance of IControllerFactory was found in the resolver as well as a custom registered provider

We are hitting the following error in some of our environments, seemingly after the app pool recycles.

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.

We are not using the ControllerBuilder to register our controller factory, only the IDependencyResolver as pointed out in the this blog

We are using Castle Windsor (seemingly unrelated), as our container, and in the Application_Start of the Global.asax, first registering all of our dependencies and calling the following to register the IDepencencyResolver.

DependencyResolver.SetResolver(new WindsorDependencyResolver(IoC));

What could be causing this exception? Any help would be appreciated.

Using the MVC DependencyResolver with Castle Windsor is not recommended as it has a design flaw: it does not release service instances when it should. See this article for a full explanation.

Instead, use the method illustrated in the Windsor documentation which uses a custom factory to inject dependencies into controllers.

For information, I had the same error message (with ninject). I don't understand why because the application started well in other machine. I tried to clear caches... but error was still present. I had redo a checkout in my repository and it was OK...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM