I am working on an ASP.NET Core API that is extensible with Plug-Ins. Because the Plug-In Assemblies need to be unloadable, I've started loading them into separate, collectible, AssemblyLoadContexts.
The Implementation basically looks like this:
// Creating a new Context for the Plugin.
AssemblyLoadContext context = new AssemblyLoadContext(directoryInfo.FullName, true);
...
// Loading every Assembly the Plugin uses into the Context.
Assembly assembly = context.LoadFromAssemblyPath(fileInfo.FullName);
...
// Creating AssemblyCatalogs with the Assemblies.
AssemblyCatalog assemblyCatalog = new AssemblyCatalog(assembly);
This works and I can use the Assemblies normally. However, the AssemblyCatalogs all have unpopulated Parts Properties and thus will not compose.
Now, if I load the Assemblies into the Default Context (AssemblyLoadContext.Default), everything works as expected, except the unloading of course.
What am I missing? Thanks for pointing me in the right direction :)
