Search code examples
prismmefcatalogbootstrapper

Prism / Mef Directory Catalog SatisfyImports


In my app I have a module that I have been referencing direct from the shell (just while I get things working).

i.e.

protected override void ConfigureAggregateCatalog()
    {
        base.ConfigureAggregateCatalog();

        AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(Bootstrapper).Assembly));            
        AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(MyModule).Assembly));
    }

In my module when I've been calling SatisfyImportsOnce for a view this has worked and I can see the view model etc being created.

However, I have now changed my bootstrapper to use a directoryCatalog for my module. I have added some post build events to copy my module assembly, pdb etc to the shell.

So now I have the following in my bootstrapper

protected override void ConfigureAggregateCatalog()
    {
        base.ConfigureAggregateCatalog();

        AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(Bootstrapper).Assembly));

        // add the directory catalog for the modules
        AggregateCatalog.Catalogs.Add(new DirectoryCatalog("Modules"));
    }

I am now able to run my app and see the views from my module but the SatisfyImportsOnce that used to work now seems to do nothing. I can't see any errors. Are there different attributes I need on my imports / exports now that I'm using the directory catalog?

Thanks.


Solution

  • No, there shouldn't be any difference in the attributes you need to use.

    It's hard to tell what's wrong, here's a blog post on general MEF debugging.