title: Why is my Windsor Container saying it can't resolve this dependency even though it can?
body: <p>Given the following code:</p>
  
  <pre><code>using Castle.DynamicProxy;
  using Castle.Facilities.TypedFactory;
  using Castle.MicroKernel.Registration;
  using Castle.Windsor;
  using System;
  using System.Linq;
  
  namespace ConsoleApplication1
  {
      class Program
      {
          static void Main(string[] args)
          {
              WindsorContainer container = new WindsorContainer();
              container.AddFacility&lt;TypedFactoryFacility&gt;();
              container.Register(Classes.FromThisAssembly()
                  .BasedOn&lt;IAuditInterceptor&gt;()
                  .WithServiceDefaultInterfaces()
                  .LifestyleTransient());
              container.Register(Classes.FromThisAssembly()
                  .BasedOn(typeof(ICommandHandler&lt;&gt;))
                  .WithServiceAllInterfaces()
                  .Configure(c =&gt; c.Interceptors&lt;IAuditInterceptor&gt;().LifestyleTransient()));
  
              container.Register(Component.For&lt;ICommandHandlerFactory&gt;().AsFactory());
  
              var factory = container.Resolve&lt;ICommandHandlerFactory&gt;();
  
              var handlers = factory.GetHandlersForCommand&lt;DummyCommand&gt;();
  
              handlers.First().Handle(new DummyCommand());
          }
      }
  
      public interface IAuditInterceptor : IInterceptor
      {
  
      }
  
      public interface ICommand
      {
  
      }
  
      public interface ICommandHandler&lt;T&gt; where T : ICommand
      {
          void Handle(T command);
      }
  
      public interface ICommandHandlerFactory
      {
          ICommandHandler&lt;T&gt;[] GetHandlersForCommand&lt;T&gt;() where T : ICommand;
      }
  
  
      public class DummyCommand : ICommand
      {
  
      }
  
      public class DummyCommandHandler : ICommandHandler&lt;DummyCommand&gt;
      {
  
          public void Handle(DummyCommand command)
          {
              Console.WriteLine("Hello from command handler");
          }
      }
  
      public class AuditInterceptor : IAuditInterceptor
      {
  
          public void Intercept(IInvocation invocation)
          {
              Console.WriteLine("Interceptor before");
              invocation.Proceed();
              Console.WriteLine("Interceptor After");
          }
      }
  }
  </code></pre>
  
  <p>The code runs and executes as expected, and the interceptor fires and the program completes normally. However, if you do a check for potentially misconfigured components, you get told that </p>
  
  <blockquote>
    <p>Some dependencies of this component could not be statically resolved.
    'ConsoleApplication1.DummyCommandHandler' is waiting for the following
    dependencies:
    - Component 'ConsoleApplication1.IAuditInterceptor' (via override) which was not found. Did you forget to register it or misspelled the
    name? If the component is registered and override is via type make
    sure it doesn't have non-default name assigned explicitly or override
    the dependency via name.</p>
  </blockquote>
  
  <p>What causes this? The code runs and executes without problem. Why does Windsor say it can't find <code>IAuditInterceptor</code>?</p>
  
  <p>This goes away if you remove the injection of <code>IAuditInterceptor</code> and register the concrete type <code>AuditInterceptor</code> by itself, like this:</p>
  
  <pre><code>container.Register(Component.For&lt;AuditInterceptor&gt;().LifestyleTransient());
  container.Register(Classes.FromThisAssembly()
              .BasedOn(typeof(ICommandHandler&lt;&gt;))
              .WithServiceAllInterfaces()
              .Configure(c =&gt; c.Interceptors&lt;AuditInterceptor&gt;().LifestyleTransient()));
  </code></pre>