1

I would like to instantiate multiple instances of multiple plugins that implement a single interface within my application and from the research I've done it requires the usage of an ExportFactoryProvider.

I am using .Net 4.5 and thought support for all things MEF were now included, but I cannot find any such class in the "System.ComponentModel.Composition" namespace or any other for that matter.

I downloaded a ported Desktop version "Microsoft.ComponentModel.Composition.Initialization.Desktop.dll", but when I add a reference to that assembly it complains that "ExportFactory" exists in both "Microsoft.ComponentModel.Composition.Initialization.Desktop.dll" and "System.ComponentModel.Composition".

Can someone please provide some direction and/or some sample code that achieves what I am going for (loading multiple instances of multiple plugins that implement a single interface)?

Thank you

offthat
  • 400
  • 2
  • 10
  • I think, the ExportFactory class is what you are looking for. For an example on how to use have a look at: http://blogs.msdn.com/b/bclteam/archive/2011/11/17/exportfactory-amp-lt-t-amp-gt-in-mef-2-alok.aspx?Redirected=true – Panos Rontogiannis Jun 25 '13 at 07:04
  • I ended up adding an interface method that returns an instance of the implementing class so that I could use the initial object that MEF instantiated for me to just create more objects of that type and I maintain them in a Dictionary. – offthat Jun 25 '13 at 19:51

0 Answers0