CreateChildContainer help

Topics: Prism v1
Mar 7, 2009 at 6:15 PM
Edited Mar 7, 2009 at 6:18 PM
I am trying to create scoped controllers and have mostly succeeded at that. The one thing I am struggling with is that I would like the controller to register an instance of a State type in it's child controller, and for each view to be able to access that state type. The problem I am having is that if I resolve a view with the child container, and I have a IUnityContainer paramters on the constructor of that view, Unity ends up filling that parameter with the main container and not with the child one.

To clarify:

1. I create a new container:   IUnityContainer childContainer = parentContainer.CreateChildContainer();

2. I resolve a view using childContainer: childContainer.Resolve<ISomeView>();

2.5. The view has a constuctor like public SomeView(IUnityContainer container)

3. The container that is injected into the view is not childContainer but parentContainer.

To me it seems that the childContainer should be returned. Am I wrong to expect that, or is this some sort of bug?

PS: The reason why I mention the state object above is that it is only added to the childContainer, so in my view there is no registered instance in the container.

Mar 8, 2009 at 6:47 PM
I updated the project to Prism 2 and the problem has resolved itself. I'm not sure where the actual problem was (Prism or Unity) but it's not there in Prism 2.