Search code examples
c#recursionpluginsmef

MEF recursive plugin search


Let's say that I have a few applications in a folder (each application has subfolders where plugins can be located):

  • Clients
    • Application A
      • ...
    • Application B
      • ...
    • Application C
      • ...
    • ...

Some files in these applications have an Export-attribute applied, others don't. Now, I want to be able to load these plugins in some of these applications. Is there a proper way to let MEF search recursively in every subfolder of a specified folder?


Solution

  • No, you will need to recurse through the directories yourself creating a DirectoryCatalog for each. Then, combine all of the DirectoryCatalogs with an AggregateCatalog to create the container.