title: Castle windsor 3.0 and ASP.NET MVC Controllers
body: <p>I am using Castle Windsor 3.0 and it worked perfectly for me until I tried to register controllers (I used WCF facility and IoC for repository/service layer). Here is my controllers installer class:</p>
  
  <pre><code>public class ControllersInstaller : IWindsorInstaller
  {
      public void Install(IWindsorContainer container, IConfigurationStore store)
      {
          RegisterAllBasedOnWithCustomComponentRegistration(container, typeof(IController),
              typeof(HomeController).Assembly,
              cr =&gt; cr.LifeStyle.Transient);
  
      }
  
      private void RegisterAllBasedOnWithCustomComponentRegistration(IWindsorContainer container, Type baseType,
      Assembly assemblyWithImplementations, Func&lt;ComponentRegistration, ComponentRegistration&lt;object&gt;&gt; customComponentRegistrationCb)
      {
          container.Register(
              AllTypes.FromAssembly(assemblyWithImplementations)
                  .BasedOn(baseType)
                  .If(t =&gt; t.Name.EndsWith("Controller"))
                  .Configure(c =&gt; customComponentRegistrationCb(c)));
      }
  }
  </code></pre>
  
  <p>And here is my controller factory:</p>
  
  <pre><code>public class WindsorControllerFactory : DefaultControllerFactory
  {
      private readonly IKernel _kernel;
  
      public WindsorControllerFactory(IKernel kernel)
      {
          _kernel = kernel;
      }
  
      public override void ReleaseController(IController controller)
      {
          _kernel.ReleaseComponent(controller);
      }
  
      public override IController CreateController(System.Web.Routing.RequestContext requestContext, string controllerName)
      {
          var controllerComponentName = controllerName + "Controller";
          return _kernel.Resolve&lt;IController&gt;(controllerComponentName);
      }
  }
  </code></pre>
  
  <p>From my global.asax I call the next method:</p>
  
  <blockquote>
    <p>InversionOfControl.InstallControllers(FromAssembly.This());</p>
  </blockquote>
  
  <p>which lies in an another project. And in there I do call the installation code:</p>
  
  <pre><code>    public static void InstallControllers(IWindsorInstaller install)
      {
          _container.Install(install);
      }
  </code></pre>
  
  <p>it seems like I am doing something wrong and I hope I am because it could be a "never use awny beta again" moment for me.</p>
  
  <p>I get the next exception : <strong>No component for supporting the service System.Web.Mvc.IController was found</strong> altough I can see the controller in the debug mode being registered in the container</p>