title: How does one import multiple plugin/parts using MEF?
body: <p>I'm new to MEF and am trying to use it to build a plug-in system, but am stuck at step one.</p>
  
  <p>I'm following an <a href="http://blogs.msdn.com/andreww/archive/2009/03/31/mef.aspx" rel="nofollow noreferrer">article by Andrew Whitechapel</a>. I've downloaded his sample code an it runs OK (if you remove one of the "exporting" assemblies - they are mutually exclusive in his sample - and reference the MEF assembly).</p>
  
  <p>The sample illustrates importing a single part. I want to import multiple parts (all based on the same interface). So, I change the sample code as follows:</p>
  
  <pre><code>[Import]
  // OLD - public Interface.ICalculate Calculate { get; set; }
  public IEnumerable&lt;Interface.ICalculate&gt; Calculators { get; set; }
  
  // OLD - Console.WriteLine(
  // OLD -     String.Format("{0}", Calculate.Circumference(4)));
  foreach (Interface.ICalculate calculator in Calculators)
  {
      Console.WriteLine(
      String.Format("{0}", calculator.Circumference(4)));
  }
  </code></pre>
  
  <p>I also imported System.Collections.Generic for the IEnumerable.</p>
  
  <p>The key change is the first one. As I understand it, this will allow me to import parts from multiple assemblies. However, I get the following error:</p>
  
  <pre><code>No valid exports were found that match the constraint
  </code></pre>
  
  <p>At this point I haven't even added multiple "plugin" assemblies. Still just have the one.</p>
  
  <p>For completeness here's his export definition (which I haven't touched) in the "plugin" class library:</p>
  
  <pre><code>[Export(typeof(Interface.ICalculate))]
  public class Calculate : Interface.ICalculate
  </code></pre>
  
  <p>Any ideas? I'm scratching my head here. I've searched SO and the MEF forums, but could find anything to enlighten me.</p>
  
  <p>I'm using VS 2008 SP1 (no 2010 beta installed) and the latest System.ComponentModel.Composition assembly (2009.26.8.0).</p>