I'm trying to eval MEF2 right now, but I'm having tons of problems figuring it out due to a number of factors (e.g., MEF2 is in flux, searches bring up MEF1 results, I'm dumb, etc).
My goals are exceedingly simple, so I'm hoping that someone who understands how it fits together can point me in the correct direction.
What I've got so far is a very simple console solution with two projects, one that hosts a plugin interface and one that implements it. The implementing project throws its built DLL into the bin folder of the plugin host, so that after building the assembly
containing the DLL should be easily discoverable. The plugin host knows nothing about the implementer
, other than any implementers are going to be accessible in the bin folder.
My goal is to do the following:
- Run the plugin host console application
- Spin up MEF2, telling it that I want types that implement IPlugin (original, I know)
- Get new instances of all types that implement IPlugin every time I ask MEF2 for it
- Have a beer, because MEF is doing all the heavy work for me, and I'm done
What I have done is create my two projects, and in the plugin host, and a bunch of MEF2 code that doesn't do anything.
So, given the following plugin defintion
public interface IPlugin
and the given console program:
static void Main(string args)
var plugins = GetPluginsViaMef2LolKThx();
foreach(var plugin in plugins)
private static IEnumerable<IPlugin> GetPluginsViaMef2LolKThx()
throw new NotImplementedException("HALP!");
could somebody do me a major solid and tell me how I can implement that method?