Could not load file or assembly ICSharpCode.SharpZipLib... When using nuGet package ExcelDataReader
Asked Answered
M

4

17

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.`

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

[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:

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/

What gives? This should work without a hitch.

Mana answered 10/3, 2012 at 1:22 Comment(1)
As one of the comments below suggests, just install/reinstall the SharpZipLib package using NuGet. That worked for me. These other ways of doing it are a little hacky, in my opinion.Antifebrile
M
18

I ran into the same issue; to resolve, I found the appropriate strong-name assembly on their codeplex project.

Downloaded the source code from http://exceldatareader.codeplex.com, grabbed the assembly from their LIB directory and referenced it from my project.

Edit May 2021
Looks like the link referenced is going away shortly; it's probably best (and easier) to follow Oleg's instructions below.

Misfeasance answered 26/3, 2013 at 19:58 Comment(1)
Can you be a little more explicit with your process please?Mana
A
5

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.

Then the solution is to download the latest (or choose the right version for your error) ICSharpCode.SharpZipLib.dll from the SharpZipLib website, and just place it in the folder where the ExcelDataReader's Excel.dll is located (no need to reference it).

Allpurpose answered 23/3, 2017 at 16:56 Comment(1)
wawwooow, Thank you very much, you just save a day! just what I was looking for. The exact way that guide was perfect and solved my problem.Flank
D
3

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:

  <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>

Diaconicon answered 22/8, 2014 at 3:20 Comment(1)
simply: install the package from nuget package manager --- this fixed my issue.Legion
D
1

ICSharpCode.SharpZipLib is strong name assembly. Assembly version number must exactly match or otherwise it fails to load. Please check assembly version.

Decidua answered 10/3, 2012 at 1:29 Comment(1)
Where would I find the assembly? It is not included as any package or in my web.config file.Mana

© 2022 - 2024 — McMap. All rights reserved.