Descarregar um arquivo dll no mef
Eu tenho alguns plugins como arquivos DLL. Meu aplicativo carrega a dll e funciona bem. mas quando tento excluir o plug-in antigo e substituí-lo por um novo, ele não me permite. como foi carregado pelo aplicativo. Descobri que, usando o appdomain, podemos fazer isso. mas não consigo encontrar uma solução na qual o mef seja usado.
Preciso de um código que possa ser executado em mef. Abaixo está o meu código usado para carregar plugins.
//Creating an instance of aggregate catalog. It aggregates other catalogs
var aggregateCatalog = new AggregateCatalog();
//Build the directory path where the parts will be available
var directoryPath = "Path to plugins folder";
//Load parts from the available dlls in the specified path using the directory catalog
var directoryCatalog = new DirectoryCatalog(directoryPath, "*.dll");
//Add to the aggregate catalog
aggregateCatalog.Catalogs.Add(directoryCatalog);
//Crete the composition container
var container = new CompositionContainer(aggregateCatalog);
// Composable parts are created here i.e. the Import and Export components assembles here
container.ComposeParts(this);