I am getting a bit frustrated with prism. Something that should be so easy is really getting me stuck!
I am trying to load my ModuleCatalog from a file. I created the ModuleCatalog.xaml file in my shell project. In the file's properties I have removed the Custom Tool action and I have set Build Action to Resource (I also tried Content).
Here is the code I have:
public class Bootstrapper : UnityBootstrapper
{
protected override IModuleCatalog GetModuleCatalog()
{
var uri = new Uri("/ShellProject;component/ModuleCatalog.xaml", UriKind.Relative);
var catalog = ModuleCatalog.CreateFromXaml(uri);
return catalog;
// I have also tried this:
//return (ModuleCatalog.CreateFromXaml(
// new Uri("ModuleCatalog.xaml", UriKind.Relative)));
}
...
When I run I get the following error:
The IModuleCatalog is required and cannot be null in order to initialize the modules.
I am stumped. The blogs I have read and the videos I have watched seem to indicate I am doing it right.
I can't think I am the only one to ever have loaded my configuration from a xaml file in wpf, but I can't find anyway around this.
Any help would be great!
NOTES:
- I am using a WPF App. There are tons of examples on how to do this in silverlight. I need it in for WPF.
- I have looked at this post and have not found it helpful for my issue: http://blogs.southworks.net/dschenkelman/2009/08/09/how-to-populate-the-module-catalog-from-xaml-in-a-wpf-application-using-the-composite-application-guidance-for-wpf-silverlight-prism-v2/
This is what I did that finally worked:
protected override IModuleCatalog GetModuleCatalog()
{
FileStream catalogStream = new FileStream(@".\ModuleCatalog.xaml",FileMode.Open);
var catalog = ModuleCatalog.CreateFromXaml(catalogStream);
catalogStream.Dispose();
return catalog;
}