C# Create module catalog from XAML file

1.3k views Asked by At

I have a problem with loading modules from a xaml file in the context of the prism library. The xaml for the modules look like this:

<Modularity:ModuleCatalog xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
         xmlns:sys="clr-namespace:System;assembly=mscorlib" 
         xmlns:Modularity="clr-namespace:Microsoft.Practices.Prism.Modularity;assembly=Microsoft.Practices.Prism">
<Modularity:ModuleInfoGroup InitializationMode="WhenAvailable">
    <Modularity:ModuleInfo Ref="file://HelloWorldModule.dll" ModuleName="HelloWorldModule" ModuleType="HelloWorldModule.Views.HelloWorldView, HelloWorldModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</Modularity:ModuleInfoGroup>

So far, the parser finds this xaml but it does not find the HelloWorldModule.dll. I could not find anything useful in the docs since these are all for Silverlight, but my project is a WFP app.

The relative path to the shell.exe is:

\Projects\QFX_Shell\bin\Debug

and the path to the HelloWorldModule.dll is:

\Projects\HelloWorldModule\bin\Debug

So the question is what value does the "Ref" attribute expect? Is it the absolute path for the HelloWorldModule.dll?

Second question is what value should the ModuleType attribute have:

namespace HelloWorldModule.Views
{
  /// <summary>
  /// Interaction logic for HelloWorldView.xaml
  /// </summary>
  public partial class HelloWorldView : UserControl
  {
    public HelloWorldView()
    {
        InitializeComponent();
    }
  }
}

Is the namespace included for the class type name?

ModuleType="HelloWorldModule.Views.HelloWorldView, HelloWorldModule...

Next question is, does the HelloWorldModule.dll to be in the same folder as the Shell.exe? Thanks, Juergen

1

There are 1 answers

1
PVitt On BEST ANSWER
  1. The ref attribute expects a path below the application path, if you use a relative path, or the absolute path, which usually doesnt work because you cannot know the installation folder during design time. To have the module catalog find your module you better copy the module to the application directory and use a relative path.
  2. The module type attribute has to be the type inside your module dll that implements the IModule interface.
  3. Yes, the namespace has to be included.
  4. See answer 1

For more advice about your questions, have a look at chapter 4, Modular Application Development of the Prism 4.0 - November 2010 manual.