Guidance for adding PlugIns via DLLs at Runtime?

I’d like to have various PlugIn .DLLs in a subdirectory below the ContentRoot, and to specify the names of the PlugIns to load at runtime in a .config file setting.

While I hope I can figure out how to do this from documentation, I thought it worthwhile to inquire if there is any existing SS doc, best practices, or links to outside documentation to accomplish this?

Below is my current code for loading PlugIns (in MyAppHost.Configure), and the ToDo: comments describe what I’d like to accomplish

// ToDo: Get the list of plugin names to install from the configuration settings (I've no problem with this)
// ToDo: Probe for assemblies that have a class that matches the name and implements IPlugIn (I can figure this out from MS documentation on probing for assemblies at runtime)
// ToDo: Load the matching assemblies into the runspace (I can figure this out from MS documentation on loading assemblies at runtime)
// ToDo: Security: ensure the assemblies being loaded matches some external registry of SHA codes to prove non-tamperable and authenticity (later, not needed in the near term)
// ToDo: Add each PlugIn to the SSAppHost (I am unsure where to start for this.  Finding the entry point to new'ing the Plugin() in the loaded assembly, and then passing that instance to PlugIns.Add is going to require a learning curve)
// This is how I'm doing it today, all is hardcoded and the main program takes a dependency on each PlugIn. Thiss is what I'm aiming to replace.
// Create the list of PlugIns to load
var plugInList = new List<IPlugin>() {
   new GUIServicesPlugin(),
   new RealEstateServicesPlugin(),
   new MinerServicesPlugin(),
   new DiskAnalysisServicesPlugin(),
};

// Load each plugin here. 
foreach (var pl in plugInList) {
    Plugins.Add(pl);
}

Thanks!

You can’t add binaries/plugins at runtime, they need to be registered on Startup which remains immutable after.

So if you need to add a plugin you will need to restart the App Domain (or .NET Core Process) so it starts up with your new plugin registered.

If you want to dynamically load plugins at runtime you can look into how Sharp Apps Plugins are loaded, where it loads all assemblies in the /plugins folder and registers them in the order listed in features App Setting, with plugins/* to tell it to load any remaining plugins it can find in any order.

Here’s the code for loading the plugin Assembly .dll’s in the /plugins folder and here’s the code used for registering them.