protected static bool PopulateCatalog(PluginManagerBase instance, string pluginFolderInAppData, List <string> pluginsToIgnore = null)
{
instance.mError = false;
ResolveEventHandler reh = new ResolveEventHandler(instance.currentDomain_AssemblyResolve);
bool succeeded = true;
try
{
AppDomain currentDomain = AppDomain.CurrentDomain;
//currentDomain.AssemblyResolve += reh;
AggregateCatalog catalog = instance.CreateCatalog(pluginFolderInAppData, pluginsToIgnore);
// Before we compose the parts, we want to pull out any .dll that doesn't have its references satisfied
// Update : this isn't going to work because sometimes a .dll references another .dll, but the other .dll
// isn't used.
//CleanUnreferencedDlls(catalog, instance);
var container = new CompositionContainer(catalog);
container.ComposeParts(instance);
succeeded = true;
}
catch (Exception e)
{
// If we get here then output won't even print out or even load.
// This invalidates all plugins, so we should show ane rror.
MessageBox.Show("Error in a plugin that shut down the plugin system: \n\n" + e.ToString());
instance.CompileErrors.Add("Error trying to load plugins: \r\n\r\n" + e.ToString());
instance.InstantiateAllListsAsEmpty();
succeeded = false;
}
finally
{
AppDomain.CurrentDomain.AssemblyResolve -= reh;
}
return(succeeded);
}