Elmah MySql Nuget包问题'无法加载文件或程序集'

时间:2012-01-08 03:16:26

标签: c# mysql nuget elmah

我正在尝试将Elmah添加到我的MVC3项目中。通过Nuget安装后,当我尝试访问elmah(通过localhost:port/elmah.axd)时,出现包含此错误的错误:

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.

我删除了mysql.data dll并添加了我自己的副本(版本6.4.4.0 - 文档说你可以覆盖新版本提供的dll),但是这个错误仍然存​​在。还有其他人遇到过这个吗?

1 个答案:

答案 0 :(得分:5)

我的解决方案是将其添加到我的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>

这基本上告诉编译器,无论何时某些东西请求版本0.0.0.0和6.4.4.0之间的MySql.Data程序集的版本,它应该改为提供版本6.4.4.0程序集。