1

I'm trying to add a new MySql database connection. My version of MySql.Data is 6.9.9.0 and is referenced as this in my EFModel project's app.config and in the Nuget Package Manager of the project.

When I test it, the connection with my server is well established, but when I click on "OK" it displays an error:

"Could not load file or assembly 'MySql.data, Version=6.9.8.0, Culture=Neutral, PublicKeyToken=BigNumber' or one of his dependencies. The found definition of the assembly's manifest doesn't correspond to the reference of the assembly."

The issue is that this version is not wrote in my solution in any config files.

Here is my app.config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

  <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
  <entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
    </providers>
  </entityFramework>
  <connectionStrings>
    <add name="UphairDbEntities" connectionString="metadata=res://*/DbModel.csdl|res://*/DbModel.ssdl|res://*/DbModel.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=***;user id=***;password=***;database=***&quot;" providerName="Mysql.Data.MysqlClient" />
  </connectionStrings>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <system.data>
    <DbProviderFactories>
      <remove invariant="MySql.Data.MySqlClient" name="MySQL Data Provider" />
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.8.3.0" newVersion="6.8.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

I'm struggling on this for 3 days but couldn't find any solution or related issue in SO or internet since every issues I found weren't about adding a new connection to a database nor about the version displayed on the error not listed in app.config which is my case. I really don't understand what can causes this.

Please help ! :/

Thientvse
  • 1,753
  • 1
  • 14
  • 23
Pierrick Martellière
  • 1,554
  • 3
  • 21
  • 42
  • For what it's worth, I'm getting an even less helpful error, when I try to build my solution. It just says: MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity, Version=6.10.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d No actual error message: just that and the project name & file. This seems to be fairly typical of recent versions of Visual Studio: give you an "error" related to a symptom of the problem, rather than anything that might help you actually diagnose the problem itself. In my case, I'm only using MySql with EF to retrieve data from a legacy database, to migrat – David Hazel Dec 26 '17 at 14:09
  • Some further research online led me to 2 possible causes of my problem: (1) that the problem was with Entity Framework 6.2, and (2) that it was with MySql.Data v6.10.5 and/or MySql.Data.Entity v6.10.5. After experimenting with changing versions of both, I have now established that the latter is the case. If I downgraded EF to 6.1 and left the MySql DLLs at v6.10.5 (or 6.10.4), my software didn't work. However, downgrading both MySql packages to 6.9.10 gave me a working solution with EF 6.1 or 6.2. – David Hazel Dec 26 '17 at 14:58
  • But my point about VS errors stands. I have had many occasions, over the past year or so, where the errors that come out of it when things don't build or deploy are pretty useless in helping to diagnose the underlying causes of the problems. If it weren't for Google and sites like stackoverflow, I would often be completely at sea, with no clues at all. This is not a good place to be in, for an IDE which costs a lot of money. – David Hazel Dec 26 '17 at 15:04
  • I suggest checking for nuget packages too. My project was missing MySql Fabric v6.9.10, after installing the Mysql Connector/Net with the same version and rebuilding the solution the site came back to life. – chepe263 Jan 19 '18 at 16:15

3 Answers3

2

[DUPLICATE] Conflicting versions of MySql.Data.dll in .Net project not allowing me to add/edit TableAdapters in my DataSets

I just had to uninstall the MySql Connector 6.9.10 then install the 6.9.8.0 version as explained in the duplicate link at the top of my answer and I didn't had to add a new connection, my bases for the two connected projects were displayed well !

This link for previous versions of MySql Connector is a pain in the ass to found, according to me !

But now I'm so relieved, hope this could help some others :D

Pierrick Martellière
  • 1,554
  • 3
  • 21
  • 42
0

Without searching to much. It's telling you that the assembly that it's trying to load is not matching the version of the one referenced in your application.config file.

To reference an alternate question here:

The .NET Assembly loader is unable to find 1.2.0.203, but did find a 1.2.0.200. This assembly does not match what was requested and therefore you get this error. In simple words, it can't find the assembly that was referenced. Make sure it can find the right assembly by putting it in the GAC or in the application path.

The located assembly's manifest definition does not match the assembly reference

This is also linked in the other answer: The located assembly’s manifest definition with name xxx.dll does not match the assembly reference

Hope that helps.

Joey Bob
  • 312
  • 8
  • 21
  • The thing is, like I said in my first post, that this is not a good version that it is trying to load, and this version isn't in any of my config files as you can see in my app.config on my first post. I want visual studio to load 6.9.9.0 and it wants to load 6.9.8.0 for some obscure reason. Any idea ? – Pierrick Martellière Nov 09 '17 at 14:19
  • I see, are you sure you have no reference to it at all? Can you check your references in Visual Studio or in the Global Assembly Cache, it's got to be picking up the wrong version from somewhere. Out of interest, have you used 6.9.8.0 in the past, I'd also check and clear your project "bin" and "obj" folders. – Joey Bob Nov 09 '17 at 14:45
  • Where are bin and proj directories located please ? – Pierrick Martellière Nov 09 '17 at 14:54
  • 1
    In Visual Studio, in the Solution Explorer window right click the project and "Open Folder in File Explorer". You'll then be in the root of that project, and you should be able to see "bin" and "obj" folders. – Joey Bob Nov 09 '17 at 14:59
  • So in my Nuget I'm using MySql.ConnectorNET.Data / Entity and Web version 6.8.3.2. I have also Mysql.Data and MySql.Data.Entity version 6.9.9.0. in the packages directory of my project, I can see that MySql.ConnectorNET.Data / MySql.ConnectorNET.Entity.EF6 directories are containing the respectives dlls MySql.Data.dll and MySql.Entity.EF.dll. The thing is I have also MySql.Data and MySql.Entity directories which contains too the two dll listed above. Could this be the source of the error ? Which package must I use ? – Pierrick Martellière Nov 09 '17 at 15:31
  • It appears that MySql.ConnectorNET.Data is deprecated. https://stackoverflow.com/questions/26679479/mysql-connectornet-data-vs-mysql-data – Pierrick Martellière Nov 09 '17 at 15:50
  • 1
    I was just trying to replicate the issue over here, and couldn't find the NuGet package for MySql.ConnectorNET.Data and over on the MySql downloads it lists "Starting with version 6.7, Connector/Net will no longer include the MySQL for Visual Studio integration." looks like they've moved it. "That functionality is now available in a separate product called MySQL for Visual Studio available using the MySQL Installer for Windows." – Joey Bob Nov 09 '17 at 15:53
  • 1
    Yes I installed this already. I will delete theses ConnectorNET packages from my projects – Pierrick Martellière Nov 09 '17 at 15:55
  • I did but the issue is still there. I found to have another version of MySql.Data, 6.10.4.0 in the GAC. How do I delete this version from the GAC please ? – Pierrick Martellière Nov 09 '17 at 16:25
  • I check too here, and the version of MySql.Data 6.9.8.0 doesn't even exist... Wtf ?? https://www.nuget.org/packages/MySql.Data/ – Pierrick Martellière Nov 09 '17 at 16:28
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/158618/discussion-between-joey-bob-and-pierrick-martelliere). – Joey Bob Nov 09 '17 at 16:32
0

This can happen when MySql.data version in the .csproj file does not match in the version in App.config file (because of manual change etc..). Try to uninstall the package and re add it again.

Devca
  • 77
  • 1
  • 2