Keeping the Shell configurable is possible with the Unity container.
The problem was that my Unity Container was not properly configured to read mapping/registrations from the app.config file. So it failed to know the mapping of IShell
at run time.
I had to override other methods along with CreateShell
in my PrismAppBootstrapper
class.
E.g.
public class PrismAppBootstrapper : UnityBootstrapper
{
protected override IModuleCatalog CreateModuleCatalog()
{
ModuleCatalog catalog = new ConfigurationModuleCatalog();
return catalog;
}
protected override void ConfigureContainer()
{
base.ConfigureContainer();
UnityConfigurationSection configurationSection =
(UnityConfigurationSection) ConfigurationManager.GetSection("unity");
if (configurationSection != null)
{
configurationSection.Configure(this.Container);
}
}
protected override DependencyObject CreateShell()
{
IShell shell = this.Container.TryResolve<IShell>();
return shell as Window;
}
protected override void InitializeShell()
{
base.InitializeShell();
Application.Current.MainWindow = (Window)this.Shell;
Application.Current.MainWindow.Show();
}
}