DotNetCorePlugins
DotNetCorePlugins copied to clipboard
Microsoft.Data.SqlClient is not supported on this platform
Hi, in a method of plugin when create a connection i've this error. If i try to execute the same code in the hoster i don't encure in this error. Where is the my issue? Thank you.
can you add some code? my first guess is maybe its your DI thats not configured correctly, but without code we wont know a thing.
I had the same problem. Have you solved it yet? @zraffaele
While not using this project but the Microsoft article we solved it by keeping a list of platform-specific assemblies.
See the code at: https://gist.github.com/ramonsmits/aef6872d20192acd403fa883c923032a
var platformSpecificAssemblies = new Dictionary<string, string>
{
["Microsoft.Data.SqlClient"] = "net6.0",
["System.Data.SqlClient"] = "netcoreapp2.1"
};
var pluginLoadContext = new PluginLoadContext(pluginLocation, platformSpecificAssemblies);
var assemblyName = AssemblyName.GetAssemblyName(pluginLocation);
return pluginLoadContext.LoadFromAssemblyName(assemblyName);
Instead of passing a lookup dictionary, there is maybe a method to probe target specific folders in a certain order depending on the runtime but we didn't want to spend time on that as this makes it work for our requirement.
After posting my last comment I just tested my last comment to probe for frameworks in a certain order and that works beautifully for our usage. I updated the gist.