I have a reference application that was working and now is broke and I cannot figure out why. The code that is giving me the problem is basically an exact copy of Prism's ModularityWithMef Quickstart example. The bootstrap module is an exact copy of the Quickstart except for adding my module discovery logic. So I'm not including that here. The problem I'm having in the Shell's View code behind with is an almost exact copy from the QuickStart's Shell Codebehind. The code is -
namespace MvvmRefVer
{
using System.ComponentModel;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Globalization;
using System.Windows;
using Microsoft.Practices.Prism.Logging;
using Microsoft.Practices.Prism.Modularity;
[Export]
public partial class Shell : Window, IPartImportsSatisfiedNotification
{
[Import(AllowRecomposition = false)]
private CallbackLogger logger;
[Import(AllowRecomposition = false)]
private IModuleManager moduleManager;
public Shell()
{
this.InitializeComponent();
}
public void OnImportsSatisfied()
{
}
private void WindowClosing(object sender, CancelEventArgs e)
{
Application.Current.Shutdown();
}
private void WindowLoaded(object sender, RoutedEventArgs e)
{
this.moduleManager.LoadModule("NavigationViewControlModule");
}
}
The problem occurs in this function Bootstrapper -
protected override DependencyObject CreateShell()
{
var d = this.Container.GetExportedValue<Shell>();
return d;
}
When the GetExportedValue is called and [Import(AllowRecomposition = false)] above definition of moduleManager is present, the function call will generate an Undefined Exception. If I comment out the Import line, the Shell will load properly, but without initializing the moduleManager.
My problem is that I don't have enough experience with MEF to understand what the problem is. While looking at the mef catalogs, I can see that the Prism Modularity library has been loaded.