I'm working with the Prism Library WPF Samples here (specifically, this one).
I'm trying to convert the sample's bootstrapper from using the Unity container to DryIoc. The original code looks like this:
class Bootstrapper : UnityBootstrapper
{
protected override DependencyObject CreateShell()
{
return Container.Resolve<MainWindow>();
}
protected override void InitializeShell()
{
Application.Current.MainWindow.Show();
}
protected override void ConfigureModuleCatalog()
{
var catalog = (ModuleCatalog)ModuleCatalog;
catalog.AddModule(typeof(ModuleAModule));
}
}
My new code looks like this:
class Bootstrapper : DryIocBootstrapper
{
protected override DependencyObject CreateShell()
{
return Container.Resolve(typeof(MainWindow), true) as DependencyObject;
}
protected override void InitializeShell()
{
Application.Current.MainWindow.Show();
}
protected override void ConfigureModuleCatalog()
{
var catalog = (ModuleCatalog)ModuleCatalog;
catalog.AddModule(typeof(ModuleAModule));
}
}
But when I try to run the new code, I get the following exception:
The Inner Exception says:
Activation error occurred while trying to get instance of type ModuleAModule, key ""
And the Inner Exception of that Exception says:
Unable to get constructor of DryIoc.Rules using provided constructor selector when resolving DryIoc.Rules {ReturnDefault} as parameter "rules"
in DryIoc.Container as parameter "container"
in ModuleA.ModuleAModule.
Code for ModuleAModule:
public class ModuleAModule : IModule
{
IRegionManager _regionManager;
Container _container;
public ModuleAModule(RegionManager regionManager, Container container)
{
_regionManager = regionManager;
_container = container;
}
public void Initialize()
{
_regionManager.RegisterViewWithRegion("ContentRegion", typeof(PersonList));
_container.RegisterTypeForNavigation<PersonDetail>();
}
}