title: Trying to figure out what this MEF Composition error means
body: <p>I have a question about the following exception I received trying to complete a call to <code>.ComposeParts(this)</code>:  </p>
  
  <blockquote>
    <p>The composition produced a single
    composition error. The root cause is
    provided below. Review the
    CompositionException.Errors property
    for more detailed information.</p>
    
    <p>1) The export
    'CustomersModule.CustomerMenu
    (ContractName="ModLibrary.IMenu")' is
    not assignable to type
    'System.Collections.Generic.IEnumerable`1[[ModLibrary.IMenu,
    ModLibrary, Version=1.0.0.0,
    Culture=neutral,
    PublicKeyToken=null]]'.</p>
    
    <p>Resulting in: Cannot set import
    'ModAppWorks.Host.Menus
    (ContractName="ModLibrary.IMenu")' on
    part 'ModAppWorks.Host'. Element:
    ModAppWorks.Host.Menus
    (ContractName="ModLibrary.IMenu") --> 
    ModAppWorks.Host</p>
  </blockquote>
  
  <p>There is a part there that seems like the error means that <code>IMenu</code> must implement <code>IEnumerable</code>. Here is my composition code:</p>
  
  <pre><code>static class Program
  {
      [STAThread]
      static void Main()
      {
          Host host = new Host();
          host.Run();
      }
  }
  
  class Host
  {
      #region Init
      public Host()
      { }
      #endregion
  
      #region Functions
      public void Run()
      {
          Compose();
  
          Application.EnableVisualStyles();
          Application.SetCompatibleTextRenderingDefault(false);
          Application.Run(new AppHost());
      }
  
      private void Compose()
      {
          var agrCatalog = new AggregateCatalog();
          var dirCatalog = new DirectoryCatalog(Path.GetDirectoryName
              (Assembly.GetExecutingAssembly().Location) + "..\\..\\..\\Extensions", "*.dll");
          var asmCatalog = new AssemblyCatalog(Assembly.GetExecutingAssembly());
  
          agrCatalog.Catalogs.Add(dirCatalog);
          agrCatalog.Catalogs.Add(asmCatalog);
  
          var hostContainer = new CompositionContainer(agrCatalog);
          hostContainer.ComposeParts(this);
      }
      #endregion
  
      #region Properties
      [Import(typeof(IMenu))]
      public IEnumerable&lt;IMenu&gt; Menus { get; set; }
      #endregion
  </code></pre>
  
  <p>I am importing a class that instances a <code>ToolStripMenuItem</code>. My export sample:</p>
  
  <pre><code>[Export(typeof(IMenu))]
  public class CustomerMenu : IMenu
  {
      #region Fields
      private System.Windows.Forms.ToolStripMenuItem CustomerMainMenu;
      private System.Windows.Forms.ToolStripSeparator mnuSeparator;
      private System.Windows.Forms.ToolStripMenuItem CustomersMenuItem;
      #endregion
  
      #region Init
      public CustomerMenu()
      {
          InitializeComponent();
          // 
          // CustomerMenu
          // 
          this.CustomerMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
          this.mnuSeparator,
          this.CustomersMenuItem});
          this.CustomerMainMenu.Name = "CustomerMenu";
          this.CustomerMainMenu.Size = new System.Drawing.Size(94, 20);
          this.CustomerMainMenu.Text = "Customer Menu";
          // 
          // toolStripMenuItem1
          // 
          this.mnuSeparator.Name = "toolStripMenuItem1";
          this.mnuSeparator.Size = new System.Drawing.Size(149, 6);
          // 
          // Customers
          // 
          this.CustomersMenuItem.Name = "Customers";
          this.CustomersMenuItem.Size = new System.Drawing.Size(152, 22);
          this.CustomersMenuItem.Text = "Customers";
      }
  
      #endregion
  
      #region Functions
      private void InitializeComponent()
      {
          this.CustomerMainMenu = new System.Windows.Forms.ToolStripMenuItem();
          this.mnuSeparator = new System.Windows.Forms.ToolStripSeparator();
          this.CustomersMenuItem = new System.Windows.Forms.ToolStripMenuItem();
      }
  
      #endregion
  </code></pre>
  
  <p>If <code>IMenu</code> is <em>not</em> required to implement <code>IEnumerable</code>, does anyone see something I might be doing wrong?</p>