title: No component for supporting the service HomeController was found - Castle Windsor error
body: <p>I read <a href="https://gist.github.com/martinnormark/3128275#file_controllers_installer.cs" rel="nofollow noreferrer">this</a> article about Casle Windsor. So I have classes BusinessLogicInstaller.cs, ControllersInstaller, IocContainer and WindsorControllerFactory. Here is the example:</p>
  
  <pre><code>public class ControllersInstaller : IWindsorInstaller
  {
      public void Install(IWindsorContainer container, IConfigurationStore store)
      {
          container.Register(AllTypes.FromThisAssembly()
              .Pick().If(t =&gt; t.Name.EndsWith("Controller"))
              .Configure(configurer =&gt; configurer.Named(configurer.Implementation.Name))
              .LifestylePerWebRequest());
      }
  }
  
  public class BusinessLogicInstaller : IWindsorInstaller
  {
      public void Install(IWindsorContainer container, IConfigurationStore store)
      {
          container.Register(
              Component
              .For&lt;IUser&gt;()
              .ImplementedBy&lt;User&gt;());
      }
  }
  
  public static class IocContainer
  {
      private static IWindsorContainer _container;
  
      public static void Setup()
      {
          _container = new WindsorContainer().Install(FromAssembly.This());
  
          WindsorControllerFactory controllerFactory = new WindsorControllerFactory(_container.Kernel);
          ControllerBuilder.Current.SetControllerFactory(controllerFactory);
      }
  }
  
  public class WindsorControllerFactory : DefaultControllerFactory
  {
      private readonly IKernel _kernel;
  
      public WindsorControllerFactory(IKernel kernel)
      {
          this._kernel = kernel;
      }
  
      public override void ReleaseController(IController controller)
      {
          _kernel.ReleaseComponent(controller);
      }
  
      protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
      {
          if (controllerType == null)
          {
              throw new HttpException(404, string.Format("The controller for path '{0}' could not be found.", requestContext.HttpContext.Request.Path));
          }
          return (IController)_kernel.Resolve(controllerType);
      }
  }
  </code></pre>
  
  <p>In the Global.asax class I have</p>
  
  <pre><code>public class MvcApplication : HttpApplication
  {
      protected void Application_Start()
      {
          AreaRegistration.RegisterAllAreas();
          RouteConfig.RegisterRoutes(RouteTable.Routes);
          BundleConfig.RegisterBundles(BundleTable.Bundles);
  
          // Add this line to Application_Start in Global.asax.cs to setup the IoC Container.
          IocContainer.Setup();
      }
  }
  </code></pre>
  
  <p>The problem is in class WindsorControllerFactory.cs in this line of code:</p>
  
  <pre><code>return (IController)_kernel.Resolve(controllerType);
  </code></pre>
  
  <p>The error is No component for supporting the service Controllers.HomeController was found. Where is the error?</p>