System.IO.FileNotFoundException: Could not load file or assembly Ionic.Zip

Jan 25, 2011 at 10:08 AM

Hi Cheeso,

I'm using VB2010 and i created a EXE file that creates a zip file. On my PC it works fine but on all other PC no. This is error:

**************************************

System.IO.FileNotFoundException: Could not load file or assembly 'Ionic.Zip, Version=1.9.1.5, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c' or one of its dependencies. The system cannot find the file specified.

*************************************

Now on my project I created an import for ionic.zip:

Imports Ionic.Zip

and I followed instructions reported on site how to insert DLL in my project.

My code is simple:

Using zip As ZipFile = New ZipFile
                n = 0
                Do Until n = listaRBS.Count
                    zip.AddFile(watch_path + "\script_IUB_link_" + listaRBS(n) + ".mo", "")
                    n += 1
                Loop
                zip.Save(watch_path + "\script_IUB_link.zip")
            End Using

I also inserted library Ionic.Zip.dll in my project using 'Add references' and path(where DLL is present) is:

D:\Software\DotNetZipLib-DevKit-v1.9\DotNetZip-v1.9\Release\

I believe to follow correctly all instructions but I don't understand where is mistake.

Why does not my EXE file work on other PCs?

I tried to find solution without success in other discussions.

Can you help me please?

 

thanks in advanced for your support

Gio

 

 

Coordinator
Jan 31, 2011 at 2:04 PM

Gio,

Your app depends on Ionic.Zip.dll.  When you copy your app to another PC, you must copy the EXE (yourapp.exe) as well as Ionic.Zip.dll.  They should both be placed in the same directory. 

This is the way .NET applications work.  When you add a reference to an external assembly, like DotNetZip (Ionic.Zip.dll), the app that is produced depends on that external assembly.  At runtime that assembly must be available for the exe to load.

There are ways to package the Ionic.Zip.dll into the EXE you produce, which would eliminate the requirement for you to copy both the EXE and the Ionic.Zip.dll to other PCs.  But that is a somewhat advanced technique, so I'd recommend considering that only after you're certain you want to tackle it.  For more information on that you can check the DotNetZip reference documentation, or the FAQ on the http://dotnetzip.codeplex.com  home page, or search through the threads on the forums at http://dotnetzip.codeplex.com/discussions , or see the code examples  available at http://dotnetzip.codeplex.com/documentation .

Good luck!

 

 

Jan 31, 2011 at 3:37 PM

hi  Cheeso,

thanks for your reply.

As you said  "There are ways to package the Ionic.Zip.dll into the EXE you produce, which would eliminate the requirement for you to copy both the EXE and the Ionic.Zip.dll to other PCs.  But that is a somewhat advanced technique, so I'd recommend considering that only after you're certain you want to tackle it."

I need exactly of it.

Can you provide some example or where I can look code example regarding this procedure?

BR,

Gio

Coordinator
Jan 31, 2011 at 9:35 PM

yes, click this page:

http://dotnetzip.codeplex.com/wikipage?title=Examples&referringTitle=Documentation

and select the example labelled "Embedding..."

Feb 1, 2011 at 2:22 PM

Hi Cheeso,

i solved it using ilmerge!!!

I hope that it is useful for someone.

this is command launched from prompt:

ilmerge.exe /target:winexe /targetplatform:v4,"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client" /out:<new name file.exe> file.exe Ionic.Zip.dll


bye
Gio

Coordinator
Feb 2, 2011 at 1:39 PM

great, thanks for the note.