C# 无法加载文件或程序集 ICSharpCode.SharpZipLib... 当使用 nuGet 包 ExcelDataReader
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9643114/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not load file or assembly ICSharpCode.SharpZipLib... When using nuGet package ExcelDataReader
提问by Travis J
Error:
错误:
Could not load file or assembly 'ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73' or one of its dependencies. The system cannot find the file specified.`
无法加载文件或程序集“ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73”或其依赖项之一。系统找不到指定的文件。`
Stack:
堆:
[FileNotFoundException: Could not load file or assembly 'ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73' or one of its dependencies. The system cannot find the file specified.]
Excel.Core.ZipWorker.Extract(Stream fileStream) +0
Excel.ExcelOpenXmlReader.Initialize(Stream fileStream) +78
[FileNotFoundException:无法加载文件或程序集“ICSharpCode.SharpZipLib,版本=0.85.5.452,Culture=neutral,PublicKeyToken=1b03e6acf1164f73”或其依赖项之一。系统找不到指定的文件。]
Excel.Core.ZipWorker.Extract(Stream fileStream) +0
Excel.ExcelOpenXmlReader.Initialize(Stream fileStream) +78
[Asp.Net Mvc3 C#]
[Asp.Net Mvc3 C#]
Using the NuGet Package ExcelDataReader I tried to simply open up a .xlsx file saved on the filesystem. Here is the code used:
使用 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);
Here is the website for the nuget package: http://exceldatareader.codeplex.com/
这是 nuget 包的网站:http://exceldatareader.codeplex.com/
What gives? This should work without a hitch.
是什么赋予了?这应该可以顺利进行。
采纳答案by denvercoder9
I ran into the same issue; to resolve, I found the appropriate strong-name assembly on their codeplex project.
我遇到了同样的问题;为了解决这个问题,我在他们的 codeplex 项目中找到了合适的强名称程序集。
Downloaded the source code from http://exceldatareader.codeplex.com, grabbed the assembly from their LIB directory and referenced it from my project.
从http://exceldatareader.codeplex.com下载源代码,从他们的 LIB 目录中获取程序集并从我的项目中引用它。
回答by linquize
ICSharpCode.SharpZipLib is strong name assembly. Assembly version number must exactly match or otherwise it fails to load. Please check assembly version.
ICSharpCode.SharpZipLib 是强名称程序集。程序集版本号必须完全匹配,否则无法加载。请检查汇编版本。
回答by george
because the dll is .net version 2.0, your project is higher, if you install the package from nuget package manager, it will auto use runtime assembly binding, the web.config/app.config file should like this:
因为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>
回答by Oleg Grishko
If what you are getting is:
如果你得到的是:
Could not load file or assembly 'ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73' or one of its dependencies. The system cannot find the file specified.
无法加载文件或程序集“ICSharpCode.SharpZipLib,版本=0.86.0.518,Culture=neutral,PublicKeyToken=1b03e6acf1164f73”或其依赖项之一。该系统找不到指定的文件。
Then the solution is to download the latest(or choose the right versionfor your error) ICSharpCode.SharpZipLib.dllfrom the SharpZipLib website, and just place it in the folder where the ExcelDataReader's Excel.dllis located (no need to reference it).
然后解决方案是从 SharpZipLib网站下载最新的(或为您的错误选择正确的版本),并将其放在 ExcelDataReader 所在的文件夹中(无需引用它)。ICSharpCode.SharpZipLib.dllExcel.dll

