title: castle windsor register a generic interface and retrieve all registered instances the inherit indirectly from it
body: <p>I have the following structure -</p>
  
  <pre><code>public interface IBaseInterface&lt;T&gt;
  {
  }
  
  public interface IChildInterface1&lt;Class1&gt; : IBaseInterface&lt;Class1&gt;
  {
  }
  
  public interface IChildInterface2&lt;Class2&gt; : IBaseInterface&lt;Class2&gt;
  {
  }
  
  public class ImplementationClass1 : IChildInterface1&lt;Class1&gt;
  {
  }
  
  public class ImplementationClass2 : IChildInterface2&lt;Class2&gt;
  {
  }
  </code></pre>
  
  <p>I want to register all types in the assembly that implement IBaseInterface directly or indirectly, so I want to be able to register ImplementationClass1 and ImplementationClass2 given IBaseInterface. And then I want to retrieve any concrete type based on the generic type definition of ChildInterface classes.</p>
  
  <p>I am registering types like this - </p>
  
  <pre><code>container.Register(
      AllTypes.FromAssemblyContaining&lt;Class1&gt;()
              .BasedOn(typeof(IBaseInterface&lt;&gt;))
              .WithService.Base()
              .Configure(c =&gt; c.LifeStyle.Transient)
       );
  </code></pre>
  
  <p>and then resolving the type using  </p>
  
  <pre><code>var impl = container.Resolve(typeof(IChildInterface1&lt;&gt;))
  </code></pre>
  
  <p>I expected this to give me an instance of ImplementationClass1, however I get the error -</p>
  
  <p>No component for supporting the service IChildInterface`1 was found</p>
  
  <p>Can someone figure out what I am doing wrong, is this even a valid scenario that I am attempting?</p>
  
  <p>This is my whole code - </p>
  
  <pre><code>using Castle.MicroKernel.Registration;
  
  namespace complexresolutionioc
  {
    class Program
    {
      static void Main(string[] args)
      {
        var container = new Castle.Windsor.WindsorContainer();
  
        container.Register(
          AllTypes.FromAssemblyContaining&lt;Class1&gt;()
                .BasedOn(typeof(IBaseInterface&lt;&gt;))
                .WithService.AllInterfaces()
                .Configure(c =&gt; c.LifeStyle.Transient)
       );
  
        var thisWorks = container.Resolve&lt;IChildInterface1&lt;Class2&gt;&gt;();
      }
    }
  
    public interface IBaseInterface&lt;T&gt;
    {
    }
  
    public interface IChildInterface1&lt;Class1&gt; : IBaseInterface&lt;Class1&gt;
    {
    }
  
    public interface IChildInterface2&lt;Class2&gt; : IBaseInterface&lt;Class2&gt;
    {
    }
  
    public class ImplementationClass1 : IChildInterface1&lt;Class1&gt;
    {
    }
  
    public class ImplementationClass2 : IChildInterface2&lt;Class2&gt;
    {
    }
  
    public class Class1 { }
    public class Class2 { }
  
  }
  </code></pre>
  
  <p>gives me this error - </p>
  
  <p>No component for supporting the service complexresolutionioc.IChildInterface1`1[[complexresolutionioc.Class2, complexresolutionioc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] was found
     at Castle.MicroKernel.DefaultKernel.Resolve(Type service) in c:\TeamCity\buildAgent\work\1ab5e0b25b145b19\src\Castle.Windsor\MicroKernel\DefaultKernel_Resolve.cs:line 172
     at Castle.Windsor.WindsorContainer.Resolve(Type service) in c:\TeamCity\buildAgent\work\1ab5e0b25b145b19\src\Castle.Windsor\Windsor\WindsorContainer.cs:line 889
     at Castle.Windsor.WindsorContainer.ResolveT in c:\TeamCity\buildAgent\work\1ab5e0b25b145b19\src\Castle.Windsor\Windsor\WindsorContainer.cs:line 978
     at complexresolutionioc.Program.Main(String[] args) in C:\MyDev\complexresolutionioc\complexresolutionioc\Program.cs:line 21    </p>
  
  <p>-ilias</p>