Can not load 7-zip library or internal COM error! Message: DLL file does not exist.

Apr 15, 2009 at 3:02 PM
Hello,
I have got a problem using the SevenZipSharp.dll. Trying it out with the following code will raise an SevenZipLibraryException.
The code is running on a Windows Server 2003 operation system. Do I have to do something special to the SevenZipSharp.dll?

Code:
using System;
using SevenZip;

namespace TestConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            SevenZip.SevenZipCompressor compressor = new SevenZipCompressor();
            compressor.CompressDirectory(@"E:\test\zip_this", @"E:\test\zip_this.zip", OutArchiveFormat.SevenZip);
        }
    }
}

Exception

Message:
Can not load 7-zip library or internal COM error! Message: DLL file does not exist.
StackTrace ("bei" is like "at" in German):
"   bei SevenZip.SevenZipLibraryManager.LoadLibrary(Object user, Enum format)\r\n   bei SevenZip.SevenZipCompressor.CompressFiles(String[] fileFullNames, String commonRoot, Stream archiveStream, OutArchiveFormat format, String password)\r\n   bei SevenZip.SevenZipCompressor.CompressDirectory(String directory, Stream archiveStream, OutArchiveFormat format, String password, String searchPattern, Boolean recursion)\r\n   bei SevenZip.SevenZipCompressor.CompressDirectory(String directory, String archiveName, OutArchiveFormat format, String password, String searchPattern, Boolean recursion)\r\n   bei SevenZip.SevenZipCompressor.CompressDirectory(String directory, String archiveName, OutArchiveFormat format)\r\n   bei Impuls.SharePoint.BackupRestore._TestConsole.Program.Main(String[] args)\r\n   bei System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)\r\n   bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)\r\n   bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()\r\n   bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)\r\n   bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n   bei System.Threading.ThreadHelper.ThreadStart()"


Thanks,
Christoph
Coordinator
Apr 15, 2009 at 8:44 PM
As i marked on the home page of this project, you must have native 7z.dll together with SevenZipSharp.dll. Download 7z.dll (for example, from the release of SevenZipSharp) and copy it to the same directory where SevenZipSharp.dll lies. Besides, you can specify the path to that library by SevenZipCompressor.SetLibraryPath() method.