title: Do not call Dispose of parts in dispose MEF
body: <p>I ran into a problem when the application ends the container does not call the Dispose method of the parts.
  Application based on MEF.</p>
  
  <p>When I explicitly call Dispose the container, then matod Dispose is called on the parts, but if you just close the program, the Dispose of the parts will not be called, why?
  How to make sure that when you close the program were caused by the Dispose method of all parts of the container MEF?</p>
  
  <pre><code>[Export(typeof(IMyClass))]
  [PartCreationPolicy(CreationPolicy.Shared)]
  public class MyClass: IDisposable, IMyClass
  {
      private bool disposed = false;
  
      public void Dispose()
      {
          Dispose(true);
  
          GC.SuppressFinalize(this);
      }
  
      protected virtual void Dispose(bool disposing)
      {
          if(!this.disposed)
          {
              if(disposing)
              {
                  // Dispose managed resources.
  
              }
  
              disposed = true;
          }
      }
  
      ~MyClass()
      {
          Dispose(false);
      }
  }
  </code></pre>