首页 > 解决方案 > ExcelDataReader 3.4 - System.IO.FileLoadException

问题描述

我正在使用 ExcelDataReader 3.4,它在我的开发人员 PC 上运行良好,但在生产 PC 上使用时,出现此错误

System.IO.FileLoadException:无法加载文件或程序集“System.IO.Compression,Version=4.2.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089”或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。(来自 HRESULT 的异常:0x80131040)

在我的项目中,我System.IO.Compression复制了本地。
我正在使用 .NET 4.5、Visual Studio 2017

标签: exceldatareaderfileloadexceptionsystem.io.compression

解决方案


我发现了这个问题。在我的 WPF 应用程序的 App.Config 中有那些行

<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral"/>
    <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0"/>
  </dependentAssembly>
</assemblyBinding>

我更改了 4.0.0.0 的版本,现在它可以工作了。


推荐阅读