title: MEF Importing assemblies in an imported assembly's constructor does not work - importing by calling a method does work?
body: <p>I'm curious why the following happens:</p>
  
  <p>When I use ImportMany in an imported assembly and call the compose method in the imported assembly's constructor, I can see that the ImportMany IEnumerable get's filled but as soon as I step out of the constructor and back in the parent assembly's code, move the mouse cursor over the just imported assembly it's ImportMany IENumerable is empty!</p>
  
  <p>If I do the composing in a method which I call from the 'parent' assembly, everything work's fine.</p>
  
  <p>Meaning the following does not work:
  Example code (parent):</p>
  
  <pre><code>    private CompositionContainer modules;
      private AggregateCatalog catalogOfModules = new AggregateCatalog();
      #region MEF Imports
      [Import(typeof(IMyTypedInterface&lt;someOtherInterface&gt;),AllowDefault=true)]
      public someOtherInterface someObject;
      public void StartProgram()
      {
          try
          {
              catalogOfModules.Catalogs.Add(new DirectoryCatalog(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + System.IO.Path.DirectorySeparatorChar + "directoryWichContainsMyAssembly"));
              modules = new CompositionContainer(catalogOfModules);
              modules.ComposeParts(this); 
              someObject.listOfModules.Count; # is 0              
          }
          catch (CompositionException)
          {
          }
      }
  </code></pre>
  
  <p>Example code (child):</p>
  
  <pre><code>[Export(typeof(IMyTypedInterface&lt;someOtherInterface&gt;))]
  public class ExampleChild{
      [ImportMany(typeof(someInterface))]
      private IEnumerable&lt;someInterface&gt; listOfModules;
      private CompositionContainer modules;
      private AggregateCatalog catalogOfModules = new AggregateCatalog();
      public ExampleChild()
      {
          catalogOfModules.Catalogs.Add(new DirectoryCatalog(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + System.IO.Path.DirectorySeparatorChar + "someDirectoryWithAssemblies"));
          modules = new CompositionContainer(catalogOfModules);
          modules.ComposeParts(this);
          listOfModules.Count; # is 2
      }
  }
  </code></pre>
  
  <p>===========================================</p>
  
  <p>but this does work</p>
  
  <p>Example code (parent):</p>
  
  <pre><code>    private CompositionContainer modules;
      private AggregateCatalog catalogOfModules = new AggregateCatalog();
      #region MEF Imports
      [Import(typeof(IMyTypedInterface&lt;someOtherInterface&gt;),AllowDefault=true)]
      public someOtherInterface someObject;
      public void StartProgram()
      {
          try
          {
              catalogOfModules.Catalogs.Add(new DirectoryCatalog(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + System.IO.Path.DirectorySeparatorChar + "directoryWichContainsMyAssembly"));
              modules = new CompositionContainer(catalogOfModules);
              modules.ComposeParts(this);     
              if (someObject != null)
              {
                  someObject.ComposeMethod();
                  someObject.listOfModules.Count; # is 2
              }
          }
          catch (CompositionException)
          {
          }
      }
  </code></pre>
  
  <p>Example code (child):</p>
  
  <pre><code>[Export(typeof(IMyTypedInterface&lt;someOtherInterface&gt;))]
  public class ExampleChild : IMyTypedInterface&lt;someOtherInterface&gt;, someOtherInterface{
      [ImportMany(typeof(someInterface))]
      private IEnumerable&lt;someInterface&gt; listOfModules;
      private CompositionContainer modules;
      private AggregateCatalog catalogOfModules = new AggregateCatalog();
      public void ComposeMethod()
      {
          catalogOfModules.Catalogs.Add(new DirectoryCatalog(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + System.IO.Path.DirectorySeparatorChar + "CM"));
          modules = new CompositionContainer(catalogOfModules);
          modules.ComposeParts(this);
          listOfModules.Count; # is 2
      }
  }
  </code></pre>
  
  <p>Could someone explain to me the reason for that behaviour?</p>