简体   繁体   中英

Elmah MySql Nuget Package Issue 'Could not load file or assembly'

I'm trying to add Elmah to my MVC3 project. After installing via Nuget, when I try to access elmah (via localhost:port/elmah.axd ), I get an error containing this:

Could not load file or assembly 'MySql.Data, Version=6.1.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The system cannot find the file specified.

I've removed the mysql.data dll and added my own copy (version 6.4.4.0 - the documentation says you can override the dll provided with a newer version), but this error remains. Has anyone else encountered this?

My solution was to add this to my web.config:

<configuration>
  <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.4.4.0" newVersion="6.4.4.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

This basically says to the compiler that whenever something requests a version of the MySql.Data assembly that's between versions 0.0.0.0 and 6.4.4.0, it should instead be supplied with the version 6.4.4.0 assembly instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM