I do not know whether this solution is suitable for your problem. But the meaning is approximately as follows:
You will need an interface that describes the functionality of the classes that will be loaded from assemblies:
public interface ISomeTypeInterface { string Name { get; } }
After that in assemblies you declare types as follows:
[Export(typeof(ISomeTypeInterface))] public class SomeType1 : ISomeTypeInterface { public string Name { get { return "Hello, world!"; } } }
Further, in the place where you need to collect it all write:
class SomeClass { [ImportMany] private ISomeTypeInterface[] SomeTypes { get; set; } } void ComposeParts() { var someClass = new SomeClass(); // Каталог, в котором нужно искать типы можно настраивать более тонко, используя других наследников ComposablePartCatalog или создавая своих using (var catalog = new DirectoryCatalog(".")) using (var container = new CompositionContainer(catalog)) { container.ComposeParts(someClass); } foreach (var t in someClass.SomeTypes) { Console.WriteLine(t.Name); } }
If this type of algorithm works for you, then I would advise using MEF. I can not say about the speed of work. We did not have to speed up this mechanism, although it is often used thickly.