#8 Items registered in child are not injected

closed
nobody
5
2012-06-20
2012-06-19
Anonymous
No

Items that are registered only in child containers and not in parent container result in the following error when used as a dependency: Can't create component '<Type>' as it has dependencies to be satisfied.

Example:
interface ITest
{
}

class Test : ITest
{
}

public class Tester
{
public Tester(ITest testObject):
}

public class Main(IWindsorContainer container)
{
IWindsorContainer child = new WindsorContainer();
container.AddChildContainer(child);
child.Register(Component.For<IText>().ImplementedBy<Test>());
Tester t = child.Resolve<Tester>();
}

Since the parent did not contain a reference for ITest, Tester will not be able to resolve because the parent container does not have the dependency.

Discussion

  • Jonathon Rossi

    Jonathon Rossi - 2012-06-20

    That is an interesting one, but you'll get strange lifetime issues doing that.

    However, this is our very old issue tracker from ~2006. Please use our issue tracker at:
    http://issues.castleproject.org/

     
  • Jonathon Rossi

    Jonathon Rossi - 2012-06-20
    • status: open --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks