尝试添加新数据库连接时,Eroor“无法加载文件或程序集MySql.data”

问题描述 投票:0回答:2

我正在尝试添加一个新的MySql数据库连接。我的MySql.Data版本是6.9.9.0,在我的EFModel项目的app.config和项目的Nuget Package Manager中被引用。

当我测试它时,与我的服务器的连接已经建立,但是当我点击“确定”时它会显示一个错误:

“无法加载文件或程序集'MySql.data,Version = 6.9.8.0,Culture = Neutral,PublicKeyToken = BigNumber'或其中一个依赖项。找到的程序集清单定义与程序集的引用不对应。 “

问题是我的解决方案中没有在任何配置文件中写入此版本。

这是我的app.config文件:

<?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>

我在这方面苦苦挣扎3天但是在SO或互联网上找不到任何解决方案或相关问题,因为我发现的每个问题都不是关于添加到数据库的新连接,也不是关于未列出的错误中显示的版本app.config这是我的情况。我真的不明白是什么原因引起的。

请帮忙 ! :/

mysql visual-studio entity-framework edmx edmx-designer
2个回答
1
投票

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

我只需卸载MySql Connector 6.9.10然后安装6.9.8.0版本,如我在答案顶部的重复链接中所述,我没有添加新连接,我的两个连接项目的基础显示良好!

据我所知,MySql Connector以前版本的这个链接很难找到屁股!

但现在我松了一口气,希望这可以帮助其他人:D


0
投票

没有多少搜索。它告诉你它正在尝试加载的程序集与application.config文件中引用的程序集的版本不匹配。

要在此处引用替代问题:

.NET程序集加载程序无法找到1.2.0.203,但确实找到了1.2.0.200。此程序集与请求的内容不匹配,因此您收到此错误。简单来说,它找不到引用的程序集。通过将其放入GAC或应用程序路径,确保它可以找到正确的程序集。

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

这也与另一个答案有关:The located assembly’s manifest definition with name xxx.dll does not match the assembly reference

希望有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.