1

I have a WinForms / .Net 4.0 application in Visual Studio 2015 Update 3. When I try to add, or edit, a TableAdapter in any of my DataSets, I get this error:

The wizard detected the following problems when configuring the TableAdapter:

Details:

Generated SELECT statement. [A]MySQL.Data.MySqlClient.MySqlConnection cannot be cast to [B]MySQL.Data.MySqlClient.MySqlConnection. Type A originates from 'MySQL.Data Version 6.9.8.0, Culture=neutral,PublicToken=c5687fc88969c44d' in context 'Default' at location 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\PrivateAssemblies\MySQL.Data.dll'. Type B originates from 'MySQL.Data, Version 6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' in context 'Default' at location 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\MySQL.Data\v4.0_6.9.9.0_c5687fc88969c44d\MySQL.Data.dll'.

Obviously it is complaining about two different versions of the MySQL.Data.dll 6.9.8 and 6.9.9. What I don't understand though is why or where is it referencing version 6.9.8.0? If I look at my project's references, it is using MySQL.Data.dll version 6.9.9.0. This is a NuGet package at location:

C:\Users\Fabs-LenovoY70\Source\Workspaces\Tracker\Tracker\packages\MySql.Data.6.9.9\lib\net45\MySql.Data.dll

I've tried the solution at [A]MySql.Data.MySqlClient.MySqlConnection cannot be cast to [B]MySql.Data.MySqlClient.MySqlConnection but didn't work.

I've searched my entire solution for any references to 6.9.8 and I've found nothing. I've been Googling for a solution for a whole day now and have found nothing that's worked. :( Any ideas anyone? Thank you...

Community
  • 1
  • 1
Fabricio Rodriguez
  • 3,769
  • 11
  • 48
  • 101

3 Answers3

6

I am having the same issues with VS 2012. I am not sure how to fix it but after spending quite a bit of time on it here is what I see is happening.

  1. Over all your/my system is at mysql.data.dll version 6.9.9.0. I am not able to downgrade this to 6.9.8.0 When I do I create other version problems with mysql.data.dll that seem to be unresolveable with my knowledge level.

  2. I chased down all 6.9.8.0 versions of the DLL and removed them, ensuring that there was a 6.9.9 version in its place. Once I have done this I am not able to add a data connection to a MySQL Database. When I try I get the error An error occurred that is normally caused by not having Visual Studio properly installed. In addition non of the previously defined data connections work.

  3. Not having MYSQL-connector-net-6.9.9 installed gives an error of "Cannot obtain provider factory for data provider named MySql.Data.MySqlClient" and you don't even get to the error described above by the OP.

    1. I have tried various connector-net versions and this does not fix the problem.

I have no references to 6.9.8.0 in any of my projects but clearly for some reason VS needs it to create the data connections.

Update:

I removed MySQL, then went through and deleted all mysql*.dll and all config files. I then used the MySQL Installer 5.7.14 found at http://dev.mysql.com/downloads/installer/

The installer still installed the mysql.data.dll version 6.9.8.0 and it still causes the error.

Update: The problem is with MySQL Connector / Net. It is using version 6.9.9.0 of the DLL and everything else is using 6.9.8.0 Go to your community installer and uninstall connector / net. Then go to https://downloads.mysql.com/archives/c-net/ and get version 6.9.8 of the connector / net. Install this and everything should be fine. It has worked on my system.

BrownPony
  • 575
  • 4
  • 12
  • Created Bug Report With MySQL. It can be found at http://bugs.mysql.com/bug.php?id=82617&thanks=2&notify=3 – BrownPony Aug 17 '16 at 17:35
  • Thanks for the answer BrownPony! This helped me get past the MySQL DB connection error. I wish this answer would be accepted as "correct". – Amos Long Apr 25 '17 at 21:16
  • Yes uninstalling 6.9.9 and installing 6.9.8 worked for me – Fabricio Rodriguez Jun 23 '17 at 09:44
  • 1
    Man I've been struggling with this for 4 days, every times I was fixing an issue another came, but I think now it is good !!!! I kinda love you hahahaha <3 – Pierrick Martellière Nov 09 '17 at 18:50
  • @Roxy'Pro I am not sure what the fix would be when MySQL was shipping a faulty install program. – BrownPony Jun 21 '18 at 01:25
  • And here we are in exactly the same place with the mysql version 8.0.16.0. Do the people at MySql even test these install programs. Its such a pita that it is almost criminal. I have already wasted 10 hrs on this and now it looks like I will try going back to 6.9.8 – BrownPony May 31 '19 at 15:02
2

Uninstalling 6.9.9 and installing 6.9.8 worked for me. I had uninstallation problems and I had to use this tool from microsoft to clear the connector install/uninstall problem https://support.microsoft.com/en-us/help/17588/fix-problems-that-block-programs-from-being-installed-or-removed Finally I had to make sure that mysql.data.dll referenced is version 6.9.8. I guess it's the only solution after spending countless hours up and down.

MbaiMburu
  • 875
  • 1
  • 10
  • 19
0

Make sure you check your app.config (or web.config) files. I had to downgrade from 6.10.8 to 6.10.7 .Net Connector. I wiped all the 6.10.8 version dlls from my system, rebuilt the project and it was still asking for 6.10.8. When you downgrade a Nuget package in Visual Studio, the .config is not altered - it was still at 6.10.8. I changed it to 6.10.7 and everything worked.

Ed Barnes
  • 41
  • 4