Bug #82617 Can't create a Data Source in VS2012 & VS2015
Submitted: 17 Aug 2016 17:18 Modified: 7 Jun 19:18
Reporter: C B Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.9.9 OS:Microsoft Windows (Windows 7)
Assigned to: CPU Architecture:Any
Tags: connector / net, DLL version conflict

[17 Aug 2016 17:18] C B
Description:
Not possible to create a dataset or table adapter in Visual Studio 2012 & 2015 due to conflicting versions of MySQL.Data.dll .

This means that no reports can be created or possibly even used. 

The error message is:

    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'.

< end error message > 

Attempting to resolve this I removed MySQL completely and deleted all mysql*.dll files on system.  I then install the current version of MySQL Installer 5.7.14 found at http://dev.mysql.com/downloads/installer/.  After the installation it was found that this installer still installed 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\PrivateAssemblies\MySQL.Data.dll'  as version 6.9.8.0 

How to repeat:
Install MySQL for Visual Studio using installer 5.7.14 found at http://dev.mysql.com/downloads/installer/

Check the the version of 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\PrivateAssemblies\MySQL.Data.dll'  is version 6.9.8.0 

1) Create a project.  

2) Execute Project> Add New Item > Data > DataSet  press Add.  This starts the wizard.

3) Right click in the DataSetx.xsd and select add > Table Adapter

4) Work your way through creating the table adaptor and enter a valid SQL Statement

5)Press Finish button and you will get the error.

Suggested fix:
Need to install the correct version of MySQL.Data.dll.

  
However replacing file version 6.9.8.0 with 6.9.9.0 creates an error in Visual Studio and no connections can be created so there is a little more to this than just replacing the file version.
[17 Aug 2016 17:21] C B
Further info = http://stackoverflow.com/questions/38891056/conflicting-versions-of-mysql-data-dll-in-net-...
[17 Aug 2016 17:27] C B
Error Message Screen Shot

Attachment: MySQL.Data.dll-version-conflict.png (image/png, text), 94.16 KiB.

[17 Aug 2016 17:28] C B
Screen Shot Added
[17 Aug 2016 20:45] C B
Figured out the problem I think.   Connector / Net is using 6.9.9 but the data adapter is using 6.9.8 as this is what is installed by one of the other installers in the MySQL Installer.  

Proof
I downloaded an archived  installer   5.7.13  from https://downloads.mysql.com/archives/installer/  and it also installed Connector / net 6.9.9.  Again there was a conflict.  

I then removed the connector / net 6.9.9 from this install and then installed the archived  connector / net  6.9.8 from https://downloads.mysql.com/archives/c-net/

This fixed the problem. Now data adapters can be created. 

I don't know which installer in the MySQL Installer is installing 6.9.8
[18 Aug 2016 7:03] Chiranjeevi Battula
Hello CB,

Thank you for the bug report.
I'm glad that you found a solution for your problem and let us know if you are still having the issue with complete repeatable steps.

Thanks,
Chiranjeevi.
[18 Aug 2016 12:53] C B
Chiranjeevi,

I have found a work around to a bug in your installer.  The installer still needs to be fixed and it took me well over 20 hours to fix this problem.   I think you need to fix your installer so that it is not installing incompatible versions of the dll's.   

Colin
[29 Sep 2016 5:48] Chiranjeevi Battula
http://bugs.mysql.com/bug.php?id=83190 marked as duplicate of this one.
[28 Nov 2016 21:37] Lou Gibson
I've been getting exactly this problem - fighting with it for two days.  Uninstalled Connector/Net 6.9.9 using the MySql Installer.  Downloaded the 6.9.8 Connector/Net msi and installed from there.  Now I can create a TableAdapter for a MySQL database.  YEAY!  THANK YOU!

I got into this trouble by installing Visual Studio 2015 Community Edition, then using the MySQL Installer to install MySQL for VIsual Studio, then running it again to install Connector/NET 6.9.9 (the only option).  

OS is Windows 10
[19 Sep 2017 8:22] Chiranjeevi Battula
http://bugs.mysql.com/bug.php?id=87798 marked as duplicate of this one.
[20 Nov 2017 7:15] Chiranjeevi Battula
http://bugs.mysql.com/bug.php?id=88544 marked as duplicate of this one.
[21 Nov 2017 7:37] Chiranjeevi Battula
http://bugs.mysql.com/bug.php?id=88570 marked as duplicate of this one.