.net Could not load file or assembly MySql.Data. Strong name validation failed (0x8013141A)

1

Error:

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)

Information:

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

Problem:

I've made a class library using MySQL to run various queries to my online database.

After including the dll in my separate project, the only line of code I'm using is the following: (which it throws the exception on)

// 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 files:

My dll project: (I did NOT sign this project)

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

My separate project: (I did NOT sign this project)

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

What I've searched/tried:

  • Made sure to use the same version of MySQL in both projects
  • Put the dll to both my library and MySQL in the bin folder of my separate project and adding them as a reference
  • Also tried adding both dlls of my library and MySQL to the separate project and selecting 'always copy'
  • Changing around the App.config file (assuming the issue is in here?)
  • Lastly, I tried signing both the dll project, and the project using the dll with the same password (checking sign the assembly). This also did nothing. :(

Thank you

c#
mysql
.net
asked on Stack Overflow Aug 19, 2017 by I'm Hungry • edited Aug 19, 2017 by I'm Hungry

1 Answer

0

Have you tried signing the project(s)? That may remove your error.

Maybe this link about your error will help: https://blogs.msdn.microsoft.com/keithmg/2012/03/20/strong-name-validation-failed-exception-from-hresult-0x8013141a/

or this stackoverflow question: Strong Name Validation Failed

answered on Stack Overflow Aug 19, 2017 by Anthony McGrath

User contributions licensed under CC BY-SA 3.0