(We are using .net framework 4.8)
So in our code this is how we get information about all installed providers that implement DbProviderFactory:
DbProviderFactories.GetFactoryClasses();
This works fine for most connectors, and was working fine for the MySql v8.0.25 connector. But when I upgraded to MySql 8.0.33, it doesnt list it anymore in the table.
In looking online people suggested adding these lines to the app.config:
<system.data>
<DbProviderFactories >
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=8.0.33.1, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
Still, that didnt fix the issue. Furthermore I tried to explicitly retrieve the MySql provider with the following line:
DbProviderFactory test = DbProviderFactories.GetFactory("MySql.Data.MySqlClient");
But that throws an exceptions that says the connector isnt installed, which it clearly is:
Has anyone come across this? I haven't been able to find any differences between the 2 versions that would cause this change in behavior, and nothing I am finding online seems to be fixing my issue. Thanks in advance.
EDIT: In playing around with some of the config settings I got the method
DbProviderFactories.GetFactoryClasses();
To find it, however when I later try to retrieve it like this:
DbProviderFactories.GetFactory(dbProvider.InvariantName)
it throws the following exception:
System.Configuration.ConfigurationErrorsException: 'Failed to find or load the registered .Net Framework Data Provider.'
Ive also tried adding the MySql.Data.dll file to the bin folder, as well as manually registering it in the GAC, but it didnt fix the issue
I took your test program from https://bugs.mysql.com/bug.php?id=113561.
I used the NuGet Package Manager to install the latest version (8.2.0) of MySql.Data.
I then edited
App.config
to contain the following:When I ran the program, it successfully retrieved v8.2.0.0 of
MySqlClientFactory
viaDbProviderFactories.GetFactoryClasses
andDbProviderFactories.GetFactory
.