Loading caliburn plug-ins

Mar 4, 2011 at 9:32 AM
Edited Mar 4, 2011 at 4:28 PM

Hi

 

I'm loading plug-ins using mef into my caliburn application. I want all Plug-ins with a UI elements to follow the same caliburn architecture an implement the presenter class where appropiate.

To Load these Plug-ins i'm doing something Like in my App class

 

private DirectoryCatalog plugins;

 

 

 

protected override Assembly[] SelectAssemblies()
        {
            var assemblies = new List<Assembly> { Assembly.GetExecutingAssembly() };
            foreach (var assemblyName in plugins.LoadedFiles)
            {
                assemblies.Add(Assembly.LoadFrom(assemblyName));
            }
            
            return assemblies.ToArray();
        }

 

 

protected override IServiceLocator CreateContainer()
        {
            var catalog = new AggregateCatalog();
            catalog.Catalogs.Add(new AssemblyCatalog(Assembly.GetExecutingAssembly()));

            var pluginDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\Plugins";
            plugins = new DirectoryCatalog(pluginDirectory);
            catalog.Catalogs.Add(plugins);

            this.container = new CompositionContainer(catalog);
            return new MEFAdapter(this.container);
        }

This i would think loads my plug-ins and my current app.

 

When i show one of my ViewModels from my plugin in a PresenterManager i get the following error "A default view was not found for...."

Is this the correct way to load plug-ins?

 

Cheers,

 

theHaggis

Coordinator
Mar 4, 2011 at 8:07 PM

That should work. Is it giving you a list of places that it searched? If so, it's likely that your naming doesn't match one of the supported patterns. You may need to add a namespace map. It's hard to tell. If you can send me a sample application, that demonstrates the problem, I may be able to help you.

Mar 14, 2011 at 3:35 PM

> The namespace map

nice one. It was just my namespaces not reflecting there location. simple fix.

just took me a week, as i was on holidays.