diff --git a/src/Microsoft.IIS.Administration/Extensibility/ModuleLoader.cs b/src/Microsoft.IIS.Administration/Extensibility/ModuleLoader.cs index 240c1d4..bce7ef4 100644 --- a/src/Microsoft.IIS.Administration/Extensibility/ModuleLoader.cs +++ b/src/Microsoft.IIS.Administration/Extensibility/ModuleLoader.cs @@ -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; } diff --git a/src/Microsoft.IIS.Administration/Extensibility/PluginAssemblyLoadContext.cs b/src/Microsoft.IIS.Administration/Extensibility/PluginAssemblyLoadContext.cs index 65b75cb..f1141a8 100644 --- a/src/Microsoft.IIS.Administration/Extensibility/PluginAssemblyLoadContext.cs +++ b/src/Microsoft.IIS.Administration/Extensibility/PluginAssemblyLoadContext.cs @@ -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;