Bug #112091 MySql .NET connector is no longer recognized by DbProviderFactories
Submitted: 16 Aug 2023 17:01 Modified: 19 Dec 2023 16:52
Reporter: Connor Shore Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:8.0.32+ OS:Windows
Assigned to: CPU Architecture:Any
Tags: .net, C#, Connector .NET

[16 Aug 2023 17:01] Connor Shore
Description:
In our application we load in Db connectors via .NET's DbProviderFactories.  We haven't had any issues with MySql .NET connectors previous to version 8.0.32.  With 8.0.32 and beyond, the installer no longer asks if you want Typical, Custom, etc for the install and just proceeds to install it (I'm sure this is intended but since this came to be it has caused issues for us).  With versions 8.0.32+, DbProviderFactories no longer recognizes the MySql connector.  I've included definitions in the app config and such but to no avail.  I've tried everything I've found online but nothing has worked.  Here is a StackOverflow question that highlights the issue more specifically:

https://stackoverflow.com/questions/76807243/dbproviderfactories-getfactoryclasses-does-no...

A fix or any help would be greatly appreciated as we are stuck using old versions of the connector as they are the only ones that work and our customers are wanting to use new connector versions.

How to repeat:
1) Install version 8.0.32 or any version newer of the MySql .net connector.
2) Attempt to get the connector via DbProviderFactories in C#/.net
3) Notice MySql doesn't appear as an installed connector.
[17 Aug 2023 11:34] MySQL Verification Team
Hello Connor,

Thank you for the bug report.
May I request you to please provide a simple test case(C#/.Net class) to reproduce this issue at our end?

Regards,
Ashwini Patil
[17 Aug 2023 14:38] Connor Shore
Here is the method we are using.  Note DbProvider is our class which is just a wrapper for holding the name, description, invariant and assembly names.

public static List<DbProvider> GetFactoryClasses(out List<DBProvider> badProviders) {
			DataTable tbl = DbProviderFactories.GetFactoryClasses();
			List<DbProvider> providers = new List<DbProvider>();
			badProviders = new List<DbProvider>();
			foreach (DataRow row in tbl.Rows)
			{
				DbProvider dbProvider = new DbProvider(row[0] as string, row[1] as string, row[2] as string, row[3] as string);
				try
				{
					DbProviderFactories.GetFactory(dbProvider.InvariantName); // will throw exception if not configured properly
					providers.Add(dbProvider);
				}
				catch (Exception ex)
				{
					badProviders.Add(dbProvider);
					log.Warn($"Could not get ADO.NET connector for {dbProvider.InvariantName}", ex);
				}
			}

			return providers;
}
[17 Aug 2023 14:39] Connor Shore
The thing to note is that DbProviderFactories.GetFactoryClasses() does not return MySql as one of the rows. However, it used to when it was pre version 8.0.32.
[18 Aug 2023 12:49] MySQL Verification Team
Hello Connor,

Thank you for the details.
Could you please provide DbProvider class(complete repeatable test case)? Make it as private if you prefer.

Regards,
Ashwini Patil
[18 Aug 2023 14:13] Connor Shore
A test .net framework project showing DbProviderFactories doesn't return mysql's connector

Attachment: DbProviderTestFiles.zip (application/x-zip-compressed, text), 24.65 KiB.

[18 Aug 2023 14:14] Connor Shore
I've attached DbProviderTestFiles.zip which contains a c# .net framework project with a simple test file to test the mysql connector's with.  Prior to 8.0.32, MySql should show up under the good providers but 8.0.32 and on should not.  Let me know if you have any issues viewing or getting the project.
[23 Aug 2023 12:56] MySQL Verification Team
Hello Connor,

Thank you for the test case.
I tried to reproduce your issue on windows 11 with Connector/NET 8.0.33, 8.0.32 and 8.0.30 using the project shared but I am not seeing any issues at my end. The output for all three versions were same. If you can provide more information, feel free to add it to this bug. Thanks.

Regards,
Ashwini Patil
[23 Aug 2023 17:22] Connor Shore
Interesting, is there something we could be doing wrong with our code? The code attached is pretty much exactly how we are getting the connectors in our engine.  What version of .NET framework did you use to test.  We are using .NET framework 4.8.  All the members of my team as well as our customers are getting the issue and our output looks as follows (each machine had a few different connectors but all of them had MySQL under the "Bad Providers" for versions above 8.0.32.  Here is sample output:
-----------------------------
Output using 8.0.28
Good providers:
Odbc Data Provider
OleDb Data Provider
OracleClient Data Provider
SqlClient Data Provider
Npgsql Data Provider
MySQL Data Provider
Bad providers:

Output using 8.0.33.1
Good providers:
Odbc Data Provider
OleDb Data Provider
OracleClient Data Provider
SqlClient Data Provider
Npgsql Data Provider

Bad providers:
MySQL Data Provider
----------------------------

I'll attach an updated version of the test project along with the installers we used just to verify we are all testing with the same version if you wouldn't mind double checking with those installers as well in case we were using some faulty or bad installers.

Any info or suggestions on what could be causing this issue would be much appreciated as well.

Thanks for the help!
[23 Aug 2023 17:25] Connor Shore
Looks like having the installers in the zip was too big to upload but these were the URLS we got the installers from:

Not working: https://downloads.mysql.com/archives/get/p/6/file/mysql-connector-net-8.0.33.1.msi

Working: https://downloads.mysql.com/archives/get/p/6/file/mysql-connector-net-8.0.28.msi
[5 Sep 2023 21:08] Connor Shore
Hello, I just wanted to check in to see if you guys had any updates on what we could be doing different to make our use case work.  This still doesn't work for our customers or anyone on our team.  If there is another support machine that this could be tested on to reproduce the issue or if you have suggestions for what to do to get the connector to show up via DbProviderFactory, it would be much appreciated as its blocking our customers from upgrading mysql versions. If you could also provide the details of the machine you tested on that it worked that could be helpful as well for us to determine what is different from the machine it worked on for you and the rest of our machines on which it doesn't work.  Thanks for the help!
[18 Sep 2023 17:13] Connor Shore
Hello, is there any update on this? Our team and customers are still completely blocked and none of us can reproduce a scenario where this works with the new connectors.  Any updates would be much appreciated.  If we can't resolve this we will open another ticket to see if someone else can test this and reproduce this issue as not a single environment we test on works as expected.
[19 Sep 2023 8:01] MySQL Verification Team
Hello Connor,

I've again tried to reproduce your issue with the test case attached DbProviderTestFiles.zip using Connector/NET 8.0.32 and 8.0.33.1 with .NET framework 6.0. Please see the attached screenshot FYR, nothing is listed under good and bad providers in the output. It takes forever to display bad providers but nothing is displayed. 
Please let us know if we are missing out something.

Regards,
Ashwini Patil
[19 Sep 2023 8:02] MySQL Verification Team
8.0.32 and 8.0.33.1 test results

Attachment: 112091_output_results.png (image/png, text), 13.16 KiB.

[19 Sep 2023 15:55] Connor Shore
Hello,
Thanks for getting back to us with your findings, we appreciate it!  Would you mind providing your Windows version as well as the version of Visual Studio you used as that may help us figure out some differences.  The program should take a matter of seconds to run so its bizarre that its taking a while and nothing is showing up.  I wrote the program using .NET Framework 4.8 (as that is what our application targets) so maybe using that version will provide better results. I'm not sure if its required but it may help if the .NET Framework 4.8 version is a Developer Pack rather than a Runtime for the purpose of this application. Let us know your findings. Thanks again for the support!
[21 Sep 2023 11:40] MySQL Verification Team
Hello Connor,

Here are the details.

OS: Windows 11
Visual Studio 2022

Let me try with .NET Framework 4.8 version and get back to you.

Regards,
Ashwini Patil
[23 Oct 2023 18:43] Connor Shore
Hello, I just want to check in and see if you guys were able to reproduce this issue with .NET Framework 4.8.  Us and our customers are still experiencing this issue. Thank you.
[12 Dec 2023 19:52] Connor Shore
Can we please have someone test this in .NET Framework 4.8 as this is a different version than .NET Framework 6 and is distinct from .NET and .NET Core.  This is a CRITICAL issue for us and our customers and we need to get this addressed as this appears to be an issue with the connector and nothing on our end.  Let me know when you have tested this with .NET Framework 4.8 and we can go from there. Thanks.
[19 Dec 2023 16:52] Connor Shore
By .NET Framework 6, I misspoke and meant .NET 6 just a FYI.