Experimentation
- Loading code on the fly from miscellaneous sources with DotNetCore 2.x
- Execute plug in
- Implement plugin interface
interface IPlugIn
{
bool Run(string param);
}
Allow to load the assembly from the file system or from a byte array
// Load assembly from the file system
var assemblyFileName = @"C:\DVT\.NET\DotNetCorePlugInExperiment\FredCoreLib\bin\Debug\netcoreapp2.1\FredCoreLib.dll";
var myPlugIn = new PlugInManager(assemblyFileName, "FredCoreLib.FredPlugIn");
myPlugIn.Load();
Console.WriteLine($"Execute PlugIn Instance : { myPlugIn.Instance.Run("myParam1") }");
// Load assembly as binary
byte[] assemblyBinary = File.ReadAllBytes(assemblyFileName);
var myPlugIn2 = new PlugInManager(assemblyBinary, "FredCoreLib.FredPlugIn");
myPlugIn2.Load();
Console.WriteLine($"Execute PlugIn Instance : { myPlugIn2.Instance.Run("myParam1") }");