MEF and DirectoryCatalog

Viewed 9048

Is there a way to safely use DirectoryCatalog to handle if the directory doesn't exist?

Here a code example of how my container is setup:

    //Create an assembly catalog of the assemblies with exports
    var catalog = new AggregateCatalog(
        new AssemblyCatalog(Assembly.GetExecutingAssembly()),
        new AssemblyCatalog(Assembly.Load("My.Second.Assembly")),
        new DirectoryCatalog("Plugins", "*.dll"));

    //Create a composition container
    var container = new CompositionContainer(catalog);

But an exception is thrown if the directory doesn't exist, and I would like to ignore that error.

1 Answers
Related