How can I unload a dll in order to delete it after a MEF recomposition?
With MEF, I compose my DLL
I work with my DLL
I recompose without this DLL
I want to delete it // => it doesn't work
How 开发者_运维技巧can I unload a dll in order to delete it after a MEF recomposition in which this dll is not composed ?
You can not unload a DLL/assembly. Only an AppDomain.
Ok so how can I 'connect' an AppDomain to MEF composition ?
MEF doesnt provide infrastructure to do that, unfortunately. You'd have to bake your own.
If you try to insert on catalog one Object Assembly like this:
Assembly assembly = Assembly.Load(System.IO.File.ReadAllBytes(Path.Combine(directoryPath, ItemPlugin)));
aggregateCatalog.Catalogs.Add(new AssemblyCatalog(assembly));
You can Delete the file later...
精彩评论