Description:
When using MySql.Data in a .NET 5.0 targeted project, the DLL is readable in the object viewer and the application compiles just fine, however when one tries to load the application, the first execution that requires use of MySql.Data causes an error to be thrown. It does not matter whether I use Nuget Package Management in Visual Studio, download and compile in Visual Studio, or download and compile using .NET 5.0 SDK command line "dotnet build". I have even removed the test projects, and manually forced .NET5.0 targeting in the MySql.Data.csproj file. No matter how I approach this, I cannot get the application to load MySql.Data.dll.
It works just fine when my projects target .Net 4.? Framework, just not .NET core frameworks. I require .NET 5.0 for this project.
---Begin Error---
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Could not load file or assembly 'MySql.Data, Version=8.0.26.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d'. The system cannot find the file specified.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at DarkRift.Server.PluginFactory.AddFile(String file, DependencyResolutionStrategy dependencyResolutionStrategy, String searchedDirectory) in C:\Users\scotm\Desktop\Unity\DarkRift 2.10.1 Sources\DarkRift.Server\PluginFactory.cs:line 164
System.IO.FileNotFoundException: Could not load file or assembly 'MySql.Data, Version=8.0.26.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d'. The system cannot find the file specified.
File name: 'MySql.Data, Version=8.0.26.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d'
[Error] PluginFactory Additional exception detail from LoaderExceptions property:
System.IO.FileNotFoundException: Could not load file or assembly 'MySql.Data, Version=8.0.26.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d'. The system cannot find the file specified.
File name: 'MySql.Data, Version=8.0.26.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d'
[Info] PluginManager Loaded plugin DatabaseProxy version 1.0.0
Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.IO.FileNotFoundException: Could not load file or assembly 'MySql.Data, Version=8.0.26.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d'. The system cannot find the file specified.
File name: 'MySql.Data, Version=8.0.26.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d'
at MySQLConnector.MySQLConnect.CreateTables()
at MySQLConnector.MySQLConnect..ctor(PluginLoadData pluginLoadData)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, Object[] args)
at DarkRift.Server.PluginFactory.Create[T](Type type, PluginBaseLoadData loadData, PluginLoadData backupLoadData) in C:\Users\scotm\Desktop\Unity\DarkRift 2.10.1 Sources\DarkRift.Server\PluginFactory.cs:line 249
at DarkRift.Server.PluginManagerBase`1.LoadPlugin(String name, Type type, PluginBaseLoadData pluginLoadData, PluginLoadData backupLoadData, Boolean createResourceDirectory) in C:\Users\scotm\Desktop\Unity\DarkRift 2.10.1 Sources\DarkRift.Server\PluginManagerBase.cs:line 62
at DarkRift.Server.ExtendedPluginManagerBase`1.LoadPlugin(String name, Type type, PluginBaseLoadData pluginLoadData, PluginLoadData backupLoadData, Boolean createResourceDirectory) in C:\Users\scotm\Desktop\Unity\DarkRift 2.10.1 Sources\DarkRift.Server\ExtendedPluginManagerBase.cs:line 55
at DarkRift.Server.PluginManager.LoadPlugins(PluginsSettings settings) in C:\Users\scotm\Desktop\Unity\DarkRift 2.10.1 Sources\DarkRift.Server\PluginManager.cs:line 103
at DarkRift.Server.DarkRiftServer..ctor(ServerSpawnData spawnData, ClusterSpawnData clusterSpawnData) in C:\Users\scotm\Desktop\Unity\DarkRift 2.10.1 Sources\DarkRift.Server\DarkRiftServer.cs:line 355
at DarkRift.Server.DarkRiftServer..ctor(ServerSpawnData spawnData) in C:\Users\scotm\Desktop\Unity\DarkRift 2.10.1 Sources\DarkRift.Server\DarkRiftServer.cs:line 189
at DarkRift.Server.Console.Program.Main(String[] args) in C:\Users\scotm\Desktop\Unity\DarkRift 2.10.1 Sources\DarkRift.Server.Console\Program.cs:line 124
How to repeat:
Write any code that relies on using MySql.Data.MySqlClient namespace that targets .NET 5.0