Make plugins unloadable
See original GitHub issueThis will require .NET Core 3.0 and up, which has added libraries to make assembly load contexts unloadable.
See https://github.com/dotnet/coreclr/issues/552, https://github.com/dotnet/coreclr/pull/18476, https://github.com/dotnet/corefx/issues/14724, and https://github.com/dotnet/coreclr/projects/9.
Update
Merged #31 which adds API when using .NET Core 3.0 to allow unloading.
Usage
Unloadable plugins is supported in .NET Core 3.0 Preview 2 and newer. To unload a plugin, make sure isUnloadable = true
and dispose the loader to trigger the unload.
var loader = PluginLoader.CreateFromAssemblyFile(
pluginDll,
sharedTypes: new [] { typeof(IPlugin) },
isUnloadable: true);
// do stuff
loader.Dispose(); // this triggers an unload
In order for this to work, you must make sure you have not left behind any variables (static, local, etc) or manually allocated memory. Once GC has collected everything, the assembly will be unloaded. See https://github.com/dotnet/coreclr/pull/22221
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:11 (9 by maintainers)
Initial implementation #31.
Usage
Unloadable plugins is supported in .NET Core 3.0 Preview 2 and newer. To unload a plugin, dispose the loader.
Merged #31 which adds API when using .NET Core 3.0 to allow unloading.
Usage
Unloadable plugins is supported in .NET Core 3.0 Preview 2 and newer. To unload a plugin, make sure isUnloadable =
true
and dispose the loader to trigger the unload.In order for this to work, you must make sure you have not left behind any variables (static, local, etc) or manually allocated memory. Once GC has collected everything, the assembly will be unloaded. See https://github.com/dotnet/coreclr/pull/22221