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.
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.
I quess MEF has it in use, but how does this match with Recompilation?!
Here is my code example. Even with local variables the file is still in use.
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.
public RecompilationExample()
{
DirectoryInfo dir = new DirectoryInfo(".\\plugin");
if (!dir.Exists)
dir.Create();
DirectoryCatalog d;
CompositionContainer c;
d = new DirectoryCatalog(".\\plugin");
d.Changed += new EventHandler<ComposablePartCatalogChangeEventArgs>(d_Changed);
c = new CompositionContainer(d);
c.ExportsChanged += new EventHandler<ExportsChangeEventArgs>(c_ExportsChanged);
c.ComposeParts(this);
}