CreateChildContainer injection

Mar 8, 2009 at 6:22 AM
I would just like to clear something up.

If I create a child container: eg:

IUnityContainer childContainer;

public SomeClass(IUnityContainer parentContainer)
childContainer = parentContainer.CreateChildContainer();

parentContainer.RegisterType<ISomeType, SomeClass>();
childContainer.RegisterType<ISomeType2, SomeClass2>();

In each class, if the constructor of each has a injected IUnityContainer parameter, which container is injected, child or parent?

In my current test it seems to be the parent both times.
Mar 8, 2009 at 8:04 AM
It should be getting the container you used to call Resolve on. If it isn't there's probably a bug.

Can you give me a small, but complete sample that demonstrates what you're trying to do?

Mar 8, 2009 at 7:46 PM
Thanks Chris,

The actual problem I had was using Prism v1. I updated to Prism v2 and everything seems to be working ok now. I'm not sure where the problem lies but it's sorted.

Thanks again for your help,