tags:

views:

35

answers:

1

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:

  1. I am using a WPF App. There are tons of examples on how to do this in silverlight. I need it in for WPF.
  2. 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;
}
+1  A: 

Hi,

To figure out what is going on you could build the Prism projects and use the .pdb files to debug them or you could simply include said projects in your solution and debug them directly from there.

If this is a large solution, just try this using a basic Quickstarts and then update your solution based on your findings from debugging the QS.

One of the huge benefits of Prism releasing its source is that in these kind of situations you can simply dig into it step by step to check where the issue is.

Damian Schenkelman