lundi 18 septembre 2023

Hot-patching "deps.json" at runtime?

I have a .NET 6.0 DLL that contains an Entity Framework Core DbContext to a SQL Server database.

If that assembly is referenced by the .NET 6.0 EXE and then called, everything works just fine.

However, if I try to use it in a plug-in concept and load the DLL via reflection like this:

var assembly = Assembly.LoadFrom("Plugin.dll");
var pluginType = assembly.GetExportedTypes()
  .Where(t => t.IsAssignableTo(typeof(IPlugin)))
  .First();
var plugin = (IPlugin)Activator.CreateInstance(pluginType);

Then I get

Microsoft.Data.SqlClient is not supported on this platform.

And the only difference is in the PluginHost.deps.json that now has no clue that at some point Microsoft.Data.SqlClient may get involved.

PluginHost.deps.json

And I was wondering if there was some hot-load function to teach the EXE the dependencies of the DLL.

The whole test endeavor can be found on GitHub





Aucun commentaire:

Enregistrer un commentaire