title: Resolving parent/child with Castle Windsor
body: <p>I am not sure calling this parent/child but here you go, I have a similar case like this:</p>
  
  <pre><code>namespace ConsoleApplication1
  {
      using System.Diagnostics;
      using System.Linq;
      using Castle.MicroKernel.Registration;
      using Castle.MicroKernel.Resolvers.SpecializedResolvers;
      using Castle.Windsor;
  
      class Program
      {
          static void Main(string[] args)
          {
              var container = new WindsorContainer();
  
              container.Kernel.Resolver.AddSubResolver(new CollectionResolver(container.Kernel));
  
              container.Register(
                  Component.For&lt;Parent&gt;().LifeStyle.Singleton,
                  Component.For&lt;IChild&gt;().ImplementedBy&lt;Child1&gt;().LifeStyle.Singleton);
  
              var p = container.Resolve&lt;Parent&gt;();
  
              // Fails...
              Debug.Assert(p.Children.First().Parent == p, "Parent should be resolved");
          }
      }
  
      class Parent
      {
          public IChild[] Children { get; set; }
      }
  
      interface IChild
      {
          Parent Parent { get; set; }
      }
  
      class Child1 : IChild
      {
          public Parent Parent { get; set; }
      }
  }
  </code></pre>
  
  <p>I have CollectionResolver added to the container. Both Parent and Child1 (with IChild service) are registered as singletons in the container. Whenever I try to resolve the Parent instance, I got my Children array populated but the Child1 instance in that array has a Parent of null. What I am expecting is the Parent property of the Child1 to be set to the Parent instance I am trying to resolve at that moment. I can understand that Parent is not fully activated yet, but since its ctor is run, can't Windsor inject this property yet? Are there any way to make this work or should I manually run some code to set Parents of child objects (which is far from ideal)?</p>
  
  <p>Thanks in advance!</p>