Rishi Bharadwaj
Rishi Bharadwaj

Reputation: 2076

Issue with MEF and Prism : A duplicate module with the name {0} has been found by the Loader

I am trying to create a very basic application using Prism, MEF and WPF. I have a WPF application project which has a Shell.xaml and Bootstrapper. Code for BootStrapper is below:

public class SimpleMefApplicationBootstrapper : MefBootstrapper
{
    protected override void ConfigureAggregateCatalog()
    {
        //base.ConfigureAggregateCatalog();
        this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(SimpleMefApplicationBootstrapper).Assembly));             
        this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(PrismApp.Module.Hello.HelloModule).Assembly));
        this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(PrismApp.Module.Hello.FinishModule).Assembly));
    }        

    protected override DependencyObject CreateShell()
    {
        return this.Container.GetExportedValue<Shell>();
    }

    protected override void InitializeShell()
    {
        //base.InitializeShell();
        Application.Current.MainWindow = (Window)this.Shell;
    }

    protected override IRegionBehaviorFactory ConfigureDefaultRegionBehaviors()
    {
        var factory = base.ConfigureDefaultRegionBehaviors();           

        return factory;
    }

In the solution i have another class library which has a View folder, View model Folder and two modules. The two modules are tied to two views so that they can used as a region. It works perfectly if i try to call only one module from botstrapper but not when i call both the modules. It gives me the error details like :

A duplicate module with the name FinishModule has been found by the Loader.

I dont understand if both the modules are having different then what is the problem. I tried changing the assemble also for both the modules but no luck.

Any ideas?

Upvotes: 1

Views: 1322

Answers (1)

davidcarr
davidcarr

Reputation: 92

Try using only one call:

public class SimpleMefApplicationBootstrapper : MefBootstrapper
{
    protected override void ConfigureAggregateCatalog()
    {
        //base.ConfigureAggregateCatalog();
        this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(SimpleMefApplicationBootstrapper).Assembly));   

        this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(PrismApp.Module.Hello.HelloModule).Assembly));
      //  this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(PrismApp.Module.Hello.FinishModule).Assembly));
    }       

Upvotes: 2

Related Questions