title: MEF unable to oversrite DirectoryCatalog file. Access Denied
body: <p>I'm having issues with MEF where I have a DirectoryCatalog and in a later stage want to overwrite the assembly and "refresh" the catalog.</p>
  
  <p>The problem i'm running into is that the file simply is "in use" and I can't overwrite the file. Normaly you are able to overwrite a .Net assembly.</p>
  
  <p>I quess MEF has it in use, but how does this match with Recompilation?!</p>
  
  <p>Here is my code example. Even with local variables the file is still in use.</p>
  
  <p>I've also tried to have the assembly in both application and plugins folder but then the app folder version is used and therefor overwriting does not make a difference.</p>
  
  <pre><code>public RecompilationExample()
  {
      DirectoryInfo dir = new DirectoryInfo(".\\plugin");
  
      if (!dir.Exists)
          dir.Create();
  
      DirectoryCatalog d; 
      CompositionContainer c;
  
      d = new DirectoryCatalog(".\\plugin");
      d.Changed += new EventHandler&lt;ComposablePartCatalogChangeEventArgs&gt;(d_Changed);
  
      c = new CompositionContainer(d);
      c.ExportsChanged += new EventHandler&lt;ExportsChangeEventArgs&gt;(c_ExportsChanged);
      c.ComposeParts(this);
  }
  </code></pre>