title: Castle Windsor - Resolving a generic implementation to a base type
body: <p>I'm trying to use Windsor as a factory to provide specification implementations based on subtypes of <code>XAbstractBase</code> (an abstract message base class in my case).</p>
  
  <p>I have code like the following:</p>
  
  <pre><code>public abstract class XAbstractBase { }
  public class YImplementation : XAbstractBase { }
  public class ZImplementation : XAbstractBase { }
  
  public interface ISpecification&lt;T&gt; where T : XAbstractBase
  {
      bool PredicateLogic();
  }
  
  public class DefaultSpecificationImplementation : ISpecification&lt;XAbstractBase&gt;
  {
      public bool PredicateLogic() { return true; }
  }
  
  public class SpecificSpecificationImplementation : ISpecification&lt;YImplementation&gt;
  {
      public bool PredicateLogic() { /*do real work*/ }
  }
  </code></pre>
  
  <p>My component registration code looks like this:</p>
  
  <pre><code>container.Register(
      AllTypes.FromAssembly(Assembly.GetExecutingAssembly())
      .BasedOn(typeof(ISpecification&lt;&gt;))
      .WithService.FirstInterface()
  )
  </code></pre>
  
  <p>This works fine when I try to resolve <code>ISpecification&lt;YImplementation&gt;</code>; it correctly resolves <code>SpecificSpecificationImplementation</code>.</p>
  
  <p>However, when I try to resolve <code>ISpecification&lt;ZImplementation&gt;</code> Windsor throws an exception:</p>
  
  <pre><code>"No component for supporting the service ISpecification'1[ZImplementation, AssemblyInfo...] was found"
  </code></pre>
  
  <p>Does Windsor support resolving generic implementations down to base classes if no more specific implementation is registered?</p>