Can not load 7-zip library or internal COM error! Message: failed to load library.

Feb 16, 2011 at 8:09 PM
Edited Feb 16, 2011 at 8:10 PM

 

Getting a "Can not load 7-zip library or internal COM error! Message: failed to load library." on the last line (console project):

            string backup = @"C:\temp\file.bak";
            string zippedBackup = @"C:\temp\file.7z";

            string applicationPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "7z.dll");
            SevenZipCompressor.SetLibraryPath(applicationPath);

            SevenZipCompressor compressor = new SevenZipCompressor();
            compressor.CompressionMethod = CompressionMethod.Lzma2;
            compressor.CompressionLevel = CompressionLevel.Normal;

            FileStream fileStream = File.Open(backup, FileMode.Open, FileAccess.Read);
            FileStream zippedFileStream = File.Open(zippedBackup, FileMode.Create, FileAccess.Write);

            compressor.CompressStream(fileStream, zippedFileStream);

Verified 7z.dll file exists using FileExists and by breakpointing.  Using 64-bit 7zip on 64-bit system.  Any ideas?

Feb 18, 2011 at 10:02 AM

me too

but sometime.i rebuild my OS system,it change well!

mybe some dll was wrong version,i guess.

Mar 11, 2011 at 11:50 AM
Edited Mar 13, 2011 at 8:36 AM

Hi all! I've faced the same problem while testing my application on 32-bit Windows XP SP3 after been developed and (successfully) tested on Windows 7 64-bit. My build configuration was x86 so I didn't use 64-bit version of 7-zip native dll. My solution is pretty simple: download the latest version of 7-ZIP, install it and then replace the 7z.dll from SevenZipSharp distributive with the same named dll from ...\Program Files\7-Zip\  that has the following description:"7z Standalone plugin". That's all.

May 3, 2011 at 7:53 PM

it's depend on what your visual studio version. ex:  if you are running 64 bit OS, but your VS is 32-bit, use 32 bit 7z.dll

Jul 10, 2012 at 6:20 PM
hyperslug wrote:

 

Getting a "Can not load 7-zip library or internal COM error! Message: failed to load library." on the last line (console project):

            string backup = @"C:\temp\file.bak";
            string zippedBackup = @"C:\temp\file.7z";

            string applicationPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "7z.dll");
            SevenZipCompressor.SetLibraryPath(applicationPath);

            SevenZipCompressor compressor = new SevenZipCompressor();
            compressor.CompressionMethod = CompressionMethod.Lzma2;
            compressor.CompressionLevel = CompressionLevel.Normal;

            FileStream fileStream = File.Open(backup, FileMode.Open, FileAccess.Read);
            FileStream zippedFileStream = File.Open(zippedBackup, FileMode.Create, FileAccess.Write);

            compressor.CompressStream(fileStream, zippedFileStream);

Verified 7z.dll file exists using FileExists and by breakpointing.  Using 64-bit 7zip on 64-bit system.  Any ideas?


See my blog post for the solution: http://blog.jongallant.com/2011/10/7-zip-dll-file-does-not-exist.html

Jul 16, 2012 at 4:40 PM

 

I don't have any issue in local but in live web server I am also facing same error : Can not load 7-zip library or internal COM error! Message: failed to load library. 

we are using the 32 bit server. and here is code

SevenZip.SevenZipExtractor.SetLibraryPath(Path.Combine(HttpContext.Current.Server.MapPath("~"), "bin", "7z.dll"));

please help me to resolve this issue.

Thanks 

Mahesh