【问题标题】:.net Could not load file or assembly MySql.Data. Strong name validation failed (0x8013141A).net 无法加载文件或程序集 MySql.Data。强名称验证失败 (0x8013141A)
【发布时间】:2018-01-27 17:54:24
【问题描述】:

错误:

An unhandled exception of type 'System.IO.FileLoadException' occurred in WindowsFormsApplication4.exe
Additional information: Could not load file or assembly 'MySql.Data, Version=8.0.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)

信息:

  • Visual Studio 2015
  • Windows 10 - x64
  • C#
  • MySQL 6.9.9

问题:

我使用 MySQL 制作了一个类库来对我的在线数据库运行各种查询。

在我的单独项目中包含 dll 后,我使用的唯一代码行如下:(它会引发异常)

// Runs a simple select statement to find matches for 'John Doe' in my online MySQL database table... and stores results to a dataset
DataSet ds = MyDllNameSpace.Database.People.Load("John", "Doe");

App.Config 文件:

我的 dll 项目:(我没有签署这个项目

<?xml version="1.0" encoding="utf-8"?>
<configuration>

<system.data>
    <DbProviderFactories>
      <remove invariant="MySql.Data.MySqlClient" />
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=8.0.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data></configuration>

我的单独项目:(我没有签署这个项目

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
    </startup>


  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-8.0.8.0" newVersion="8.0.8.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

我搜索过/尝试过的内容:

  • 确保在两个项目中使用相同版本的 MySQL
  • 将 dll 放入我的库和 MySQL 中的我的单独项目的 bin 文件夹中,并将它们添加为参考
  • 还尝试将我的库和 MySQL 的 dll 添加到单独的项目中并选择“始终复制”
  • 更改 App.config 文件(假设问题出在此处?)
  • 最后,我尝试对 dll 项目和使用相同密码的 dll 的项目进行签名(检查对程序集进行签名)。这也无济于事。 :(

谢谢

【问题讨论】:

  • 经过数小时试图找出问题...原来是由于在包管理器中使用了最新的预发行版 MySql.Data。切换到最新的 STABLE 版本后,一切正常。

标签: c# mysql .net


【解决方案1】:

您是否尝试过签署项目?这可能会消除您的错误。

也许这个关于你的错误的链接会有所帮助:https://blogs.msdn.microsoft.com/keithmg/2012/03/20/strong-name-validation-failed-exception-from-hresult-0x8013141a/

或者这个stackoverflow问题: Strong Name Validation Failed

【讨论】:

  • 是的,我忘了提。我尝试签署 dll 项目,以及使用 dll 的项目(都使用相同的密码)。这是我第一次签署一个项目,所以希望我没有做任何愚蠢的事情来导致这个。我会检查这些链接,但我想我已经看过了。感谢您的回复
猜你喜欢
  • 1970-01-01
  • 2014-02-26
  • 2014-11-19
  • 2016-12-22
  • 1970-01-01
  • 2013-08-04
  • 1970-01-01
  • 2021-02-12
  • 2014-01-30
相关资源
最近更新 更多