title: MEF Importing null
body: <p>First of all: You all are great, I very often search this site for MEF answers.</p>
  
  <p>My problem is the following:</p>
  
  <p>I have several assemblies with many [Imports] in them and one main application where the assembling takes place. Now the problem is, that those Imports do not get "filled" they are always staying null.</p>
  
  <p>I've tried to reproduce this behaviour in a simple small project and came up with the following source code. </p>
  
  <p>Am I missunderstanding some things about MEF?</p>
  
  <p>Please help! Thank you all!</p>
  
  <p>Assembly Interfaces:</p>
  
  <pre><code>namespace Interfaces
  {
      public interface IClass1
      {
          void Trigger();
      }
  
      public interface IClass2
      {
          void Trigger();
      }
  
      public interface IClass3
      {
          void Trigger();
      }
  }
  </code></pre>
  
  <p>Assembly Library1:</p>
  
  <pre><code>namespace Library1
  {
      [Export(typeof(IClass1))]
      public class Class1:IClass1
      {
  
          #region IClass1 Members
  
          public void Trigger()
          {
  
          }
  
          #endregion
      }
  }
  </code></pre>
  
  <p>Assembly Library2:</p>
  
  <pre><code>namespace Library2
  {
      [Export(typeof(IClass2))]
      public class Class2:IClass2
      {
          [Import]
          public IClass1 Class1 { get; set; }
  
          public void Trigger()
          {
          }
      }
  }
  </code></pre>
  
  <p>In the main programm I assemble the whole Mef stuff doing the following:</p>
  
  <pre><code>namespace MEFTest
  {
      public class mefStart
      {
          public CompositionContainer Container { get; private set; }
  
          public void Start()
          {
              AggregateCatalog catalog = new AggregateCatalog();
  
              AssemblyCatalog assemblyCatalog = new AssemblyCatalog(typeof(Program).Assembly);
              DirectoryCatalog directoryCatalog = new DirectoryCatalog(".", "Library*.dll");
              catalog.Catalogs.Add(directoryCatalog);
              catalog.Catalogs.Add(assemblyCatalog);
  
              this.Container = new CompositionContainer(catalog);
  
              CompositionBatch batch = new CompositionBatch();
              batch.AddExportedValue(this.Container);
  
              this.Container.Compose(batch);
              this.Container.ComposeParts(this);
          }
      }
  }
  </code></pre>
  
  <p>But after that the following class does not have any of the imports filled:</p>
  
  <pre><code>namespace MEFTest
  {
      public class Class3:IClass3
      {
          [Import]
          public IClass1 Class1 { get; set; }
  
          [Import]
          public IClass2 Class2 { get; set; }
  
          public void Trigger()
          {
              Class1.Trigger();
              Class2.Trigger();
          }
      }
  }
  </code></pre>
  
  <p>When I am looking into the container, I see that the IClass1 and the ICLass2 were composed.</p>
  
  <p>Why are the [Import]'s in Class3 not being satisfied? I guess I am missing something completely...</p>
  
  <p>Thank you all in advance for your help!</p>
  
  <p>Michael</p>