fix(plugins): close LA5 host lifecycle review
This commit is contained in:
parent
95f4be94db
commit
fbe9c8a288
25 changed files with 1043 additions and 120 deletions
|
|
@ -48,13 +48,15 @@ public static class PluginLoader
|
|||
|
||||
if (pluginType is null)
|
||||
{
|
||||
var released = new WeakReference(alc);
|
||||
alc.Unload();
|
||||
return new LoadedPlugin(
|
||||
manifest,
|
||||
Plugin: null,
|
||||
LoadContext: null,
|
||||
Error: new InvalidOperationException(
|
||||
$"no IAcDreamPlugin implementation found in {manifest.EntryDll}"));
|
||||
$"no IAcDreamPlugin implementation found in {manifest.EntryDll}"),
|
||||
ReleasedLoadContext: released);
|
||||
}
|
||||
|
||||
instance = (IAcDreamPlugin)Activator.CreateInstance(pluginType)!;
|
||||
|
|
@ -68,9 +70,15 @@ public static class PluginLoader
|
|||
// as an Enable failure before releasing the collectible context.
|
||||
try { instance?.Disable(); }
|
||||
catch { }
|
||||
WeakReference? released = alc is null ? null : new WeakReference(alc);
|
||||
try { alc?.Unload(); }
|
||||
catch { }
|
||||
return new LoadedPlugin(manifest, Plugin: null, LoadContext: null, Error: ex);
|
||||
return new LoadedPlugin(
|
||||
manifest,
|
||||
Plugin: null,
|
||||
LoadContext: null,
|
||||
Error: ex,
|
||||
ReleasedLoadContext: released);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue