16

错误:

无法加载文件或程序集 'ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73' 或其依赖项之一。系统找不到指定的文件。`

堆:

[FileNotFoundException:无法加载文件或程序集“ICSharpCode.SharpZipLib,版本=0.85.5.452,文化=中性,PublicKeyToken=1b03e6acf1164f73”或其依赖项之一。系统找不到指定的文件。]
Excel.Core.ZipWorker.Extract(Stream fileStream) +0
Excel.ExcelOpenXmlReader.Initialize(Stream fileStream) +78

[Asp.Net Mvc3 C#]

使用 NuGet 包 ExcelDataReader,我尝试简单地打开保存在文件系统上的 .xlsx 文件。这是使用的代码:

string filePath = HttpContext.Server.MapPath("~/blank3.xlsx");
FileStream stream = System.IO.File.Open(filePath, FileMode.Open, FileAccess.Read);
IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);

这是 nuget 包的网站: http ://exceldatareader.codeplex.com/

是什么赋予了?这应该可以顺利进行。

4

4 回答 4

18

我遇到了同样的问题;为了解决这个问题,我在他们的 codeplex 项目中找到了适当的强名称程序集。

从http://exceldatareader.codeplex.com下载源代码,从他们的 LIB 目录中获取程序集并从我的项目中引用它。

编辑 2021 年 5 月
看起来引用的链接很快就会消失;遵循以下Oleg 的说明可能是最好的(也更容易)。

于 2013-03-26T19:58:17.847 回答
5

如果你得到的是:

无法加载文件或程序集 'ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73' 或其依赖项之一。该系统找不到指定的文件。

那么解决方法就是从SharpZipLib网站上下载最新的(或者为你的错误选择正确的版本) ,然后把它放在ExcelDataReader所在的文件夹中(不需要引用它)。ICSharpCode.SharpZipLib.dllExcel.dll

于 2017-03-23T16:56:32.643 回答
3

因为 dll 是 .net 版本 2.0,所以你的项目更高,如果你从 nuget 包管理器安装包,它将自动使用运行时程序集绑定,web.config/app.config 文件应该是这样的:

  <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="ICSharpCode.SharpZipLib" publicKeyToken="1b03e6acf1164f73" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-0.85.4.369" newVersion="0.85.4.369" />
  </dependentAssembly>
</assemblyBinding>

于 2014-08-22T03:20:33.320 回答
0

ICSharpCode.SharpZipLib 是强名称程序集。程序集版本号必须完全匹配,否则无法加载。请检查汇编版本。

于 2012-03-10T01:29:33.443 回答