Fixed PluginAssemblyLoadContext so it won't reload already loaded assemblies. (#214)

The appveyor build did not succeed but I guess that's OK since I will continue to work on this branch.
This commit is contained in:
Baris Caglar 2018-11-16 13:54:14 -08:00 коммит произвёл Peter Hsu
Родитель 2f5a369eed
Коммит 1887262434
2 изменённых файлов: 13 добавлений и 2 удалений

Просмотреть файл

@ -39,12 +39,17 @@ namespace Microsoft.IIS.Administration
Log.Logger.Debug($"Loading plugin {assemblyName}");
Assembly assembly = _loader.LoadFromAssemblyPath(assemblyPath);
_loadedAssemblies.Add(assembly);
//
// Every module should expose a type called Startup in a namespace equivalent to the assembly name
Type type = assembly.GetType(assemblyName + ".Startup");
IModule module = (IModule) Activator.CreateInstance(type);
Type type = assembly.GetType(assemblyName + ".Startup");
IModule module = (IModule)Activator.CreateInstance(type);
_moduleHolder.Add(module);
return assembly;
}

Просмотреть файл

@ -24,6 +24,12 @@ namespace Microsoft.IIS.Administration
protected override Assembly Load(AssemblyName assemblyName)
{
AssemblyName loaded = Assembly.GetEntryAssembly().GetReferencedAssemblies().FirstOrDefault(a => a.Name.Equals(assemblyName.Name));
if (loaded != null)
{
return Assembly.Load(loaded);
}
Assembly asm = null;