title: Castle windsor controller factory and repository not resolving
body: <p>I am currently testing out Castle Windsor vs. Ninject, and I really like what Windsor has to offer, I am just having an issue with a repository injection.</p>
  
  <p>So, here's the setup...I have a ControllersInstaller that looks like this...</p>
  
  <pre><code>public class ControllersInstaller : IWindsorInstaller
  {
      public void Install(IWindsorContainer container, IConfigurationStore store)
      {
          container.Register(FindControllers().Configure(ConfigureControllers()));
      }
  
      private BasedOnDescriptor FindControllers()
      {
          return AllTypes.FromThisAssembly()
              .BasedOn&lt;IController&gt;()
              .If(Component.IsInSameNamespaceAs&lt;HomeController&gt;())
              .If(t =&gt; t.Name.EndsWith("Controller"));
  
      }
  
      private ConfigureDelegate ConfigureControllers()
      {
          return c =&gt; c.LifeStyle.Transient;
      }
  }
  </code></pre>
  
  <p>A context installer that looks like this...</p>
  
  <pre><code>public class ContextInstaller : IWindsorInstaller
  {
      public void Install(IWindsorContainer container, IConfigurationStore store)
      {
          container.Register(AllTypes.FromThisAssembly()
              .Where(t =&gt; t.Name == "MyContext"));
      }
  }
  </code></pre>
  
  <p>And a repo installer that looks like...</p>
  
  <pre><code>public class RepoInstaller : IWindsorInstaller
  {
  
      public void Install(IWindsorContainer container, IConfigurationStore store)
      {
          container.Register(AllTypes.FromThisAssembly()
              .Where(type =&gt; type.Name.EndsWith("Repo"))
              .WithService.DefaultInterface()
              .Configure(c =&gt; c.LifeStyle.Singleton));
      }
  }
  </code></pre>
  
  <p>Then in Global.asax I am registering them by...</p>
  
  <pre><code>private static void BootstrapContainer()
      {
          var container = new WindsorContainer()  // Create a container to hold the dependencies
              .Install(
              new ContextInstaller(),
              new RepoInstaller(),
               new ControllersInstaller()
              );      // Scan this assembly for all IWindsorInstaller
  
          var controllerFactory = new WindsorControllerFactory(container.Kernel);     // Create a new instance
          ControllerBuilder.Current.SetControllerFactory(controllerFactory);          // Use my factory instead of default
      }
  </code></pre>
  
  <p>My home controller looks like...</p>
  
  <pre><code>    public class HomeController : Controller
  {
      IMyRepo _repo;
  
      public HomeController(MyRepo repo)
      {
          _repo = repo;
      }
  </code></pre>
  
  <p>But for whatever reason when I debug the thing I get...
  Some dependencies of this component could not be statically resolved. MyProject.Controllers.HomeController is waiting for the following dependencies: Services: - MyProject.Models.MyRepo which was not registered. </p>
  
  <p>And I can't figure out why! I tried making my repo installer install as singleton, and I tried reordering the Registration process so the repo get's setup before the controllers.</p>
  
  <p>When I debug and hit the controller factory line in Global.asax, it says that everything except HomeController has been resolved correctly.</p>
  
  <p>Thoughts?</p>