Jan 2, 2009 at 3:41 PM
Edited Jan 2, 2009 at 3:42 PM
Looking at your code, it seems that you are creating the Shell twice:
When you resolve the UIService class, the Shell is injected in the constructor through the container creating an instance of the Shell.
When you resolve the ShellPresenter, another instance of the Shell is created by the container and injected in the View property of the class.
If this is the cause of your error, you could do the following to avoid creating the Shell twice:
Register the Shell as a singleton. In this way the container always injects the same instance:
Note: The ConfigureContainer method is the place where you typically write code to register services in the Bootstrapper class.
protected override void ConfigureContainer()
Container.RegisterType<IShell, Shell>(new ContainerControlledLifetimeManager());
Container.RegisterType<IUIService, UIService>(new ContainerControlledLifetimeManager());
protected override DependencyObject CreateShell()
ShellPresenter presenter = Container.Resolve<ShellPresenter>();
IShell view = presenter.View;
return view as DependencyObject;
Hope it helps.