title: Running into trouble with MEF
body: <p>I'm trying to create an extensible "utility" console application in .NET 4, and I figured using MEF to do this would give me the best in terms of flexibility and extensibility.</p>
  
  <p>So I started setting up a MEF <strong>interface:</strong></p>
  
  <pre><code>public interface IUtility
  {
      string Title { get; }
      string Version { get; }
  
      void Execute(UtilContext context);
  }
  </code></pre>
  
  <p>And then I created two nearly identical test plugins - just to see how this stuff works:</p>
  
  <p><strong>MEF Plugin:</strong></p>
  
  <pre><code>[Export(typeof(IUtility))]
  public class Utility1 : IUtility
  {
      public string Title
      {
          get { return "Utility 1"; }
      }
  
      public string Version
      {
          get { return "1.0.0.0"; }
      }
  
      public void Execute(UtilContext context)
      {
      }
  }
  </code></pre>
  
  <p>The console app that acts as the "host" for the MEF plugins looks something like this:    </p>
  
  <pre><code>[ImportMany]
  public IEnumerable&lt;IUtility&gt; _utilities { get; set; }
  
  public void SetupMEF()
  { 
     string directory = ConfigurationManager.AppSettings["Path"];
  
     AggregateCatalog catalog = new AggregateCatalog();
     catalog.Catalogs.Add(new DirectoryCatalog(directory));
  
     CompositionContainer container = new CompositionContainer(catalog);
     container.ComposeParts(this);
  }
  </code></pre>
  
  <p>I checked - the directory is being read from the <code>app.config</code> correctly, and the plugin modules (*.dll files) are present there after solution has been built. Everything seems just fine..... until I get this exception:</p>
  
  <blockquote>
    <p>System.Reflection.ReflectionTypeLoadException was unhandled<br>
    Message = Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.</p>
    
    <p><em>LoaderException:</em><br>
    Method 'get_Version' in type 'Utility.Utility1' from assembly 'Utility1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation</p>
  </blockquote>
  
  <p>Hmmm.... what exactly is MEF trying to tell me here? And how do I fix this problem? Any thoughts, ideas, pointers? </p>
  
  <p>Did I break some convention by having a property called <code>Version</code> of my own? Is that something reserved by MEF? </p>