2

I am trying to use IconicZip to perform some unzipping tasks in my Visual C# 4.0 application. But when i try to test my application, i receive the error: Could not load file or assembly 'Ionic.Zip, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c' or one of its dependencies. The system cannot find the file specified.

My library for IconicZip is located in: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client with all the other default libraries.

I've added the reference to it using the add reference wizard and it shows no errors in the code:

using (ZipFile zip1 = ZipFile.Read(uiFindRar.FileName))
{  
    foreach (ZipEntry zip in zip1)
    {
        zip.Extract(unpackDirectory, ExtractExistingFileAction.OverwriteSilently);
    }
}

The only error i experience is during runtime.

sh3rifme
  • 1,054
  • 1
  • 11
  • 26
  • 2
    Don't copy assemblies to that folder; it won't do any good. Instead, just use NuGet. – SLaks Feb 28 '14 at 15:53
  • 2
    Try setting `Copy Local` on the `Ionic.Zip` to `True` – Simon Feb 28 '14 at 15:53
  • "or one of its dependencies. The system cannot find the file specified." It's also worth checking if all the needed dependencies are installed, use Dependency Walker, for example. – Rodrigo Silva Feb 28 '14 at 15:54

1 Answers1

3

Verify your assembly reference has Copy Local = true. Often times the assembly reference will default to False because Visual Studio expects the DLL to be in the Global Assembly Cache:

enter image description here

wizulus
  • 5,653
  • 2
  • 23
  • 40
  • if you are using `PackageReference` you might want to look at [this](https://stackoverflow.com/a/55105073/426315) link – itsho Aug 04 '19 at 09:31
  • Excellent point, @itsho, but that link is about excluding assemblies, and this question is about including them. Also this question predates PackageReference by about 3 years.. That being said, is there a way to improve the answer that addresses PackageReference for including assemblies where it would otherwise not? – wizulus Aug 04 '19 at 15:33
  • 1
    @wizulus you are correct, I think that `PackageReference` are all CopyLocal=True by default. the reason I added the comment is because I had an issue and found out that one of the projects with package.config had CopyLocal=True and the other project had `PackageReference` with the ignore flag. so I had to "align" the project files. – itsho Aug 05 '19 at 14:06