I am trying to use MEF to load a DLL as an when it is needed, however, the information in tutorials I have read hasn’t been the most helpful.
This site gives a bit of code (shown below) but doesn’t really explain anything.
private void LoadPlugins() {
var catalog = new AssemblyCatalog(Assembly.GetExecutingAssembly());
var container = new CompositionContainer(catalog);
var batch = new CompositionBatch();
batch.AddPart(this);
container.Compose(batch);
}
Basically I have an interface with a Run method and I am implementing that interface with several DLLs. What I’m after is to be able to do something like this (pseudo code)
bob = LoadDll(dllPath);
bob.Run();
Is there a way to specify the type of “bob” or would it be generic? If anyone can help I would really appreciate it!
does this article help: MEF Load Plugins(dlls) from folder not in Executing assembly but another dll.Can you help?
basically, the solution, i think, would be to use AssemblyCatalog to load your assembly.