Hi,
I have an application which makes use of Windsor's child container feature
extensively. Recently, I fall into the following problem:
- Component Root has one dependency which is Branch.
- Root is registered into the parent container.
- Branch is registered into the child container.
- Problem: child can resolve Branch successfully but fail to resolve Root.
I guess the default behavior of Windsor is that it is resolving a service
which is registered to a container A, it won't look for dependency
registrations in the child containers of A.
Could anyone help me with a couple of questions:
1. Why is that chosen as the default behavior?
2. How do I make resolving Branch work?
Thank you,
Thuan.
Test code:
public interface IRoot { }
public interface IBranch { }
public class Root : IRoot
{
public Root(IBranch branch)
{
}
}
public class Branch : IBranch
{ }
[TestMethod]
public void TestWindsorChildContainer()
{
var container = new WindsorContainer();
container.Register(Component.For<IRoot>().ImplementedBy<Root>());
var child = new WindsorContainer();
child.Parent = container;
child.Register(Component.For<IBranch>().ImplementedBy<Branch>());
Assert.IsNotNull(child.Resolve<IBranch>()); // this is ok
Assert.IsNotNull(child.Resolve<IRoot>()); //
HandlerException: Can't create component 'Root' as it has dependencies to
be satisfied.
}
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/d/optout.