我正在使用MEF和System.ComponentModel.Composition.dll来加载一些dll文件。
我的操作类似于:
AggregateCatalog catalog = new AggregateCatalog(new AssemblyCatalog(Assembly.GetExecutingAssembly()), new DirectoryCatalog(directory));
_container = new CompositionContainer(catalog);
_container.ComposeParts(this);
导入我的dll。
一段时间后,我想更新我的dll,但是如果我尝试删除它,我会遇到访问被拒绝的问题,因为它已经被程序使用了。
如何释放dll,替换为新的dll并重新加载dll?(不关闭程序)
感谢您提前的帮助。