1
Vote

Loading native dlls not working in web project

description

Fixed it by changing function Load7ZipLibrary to:
 
private static SafeLibraryHandle Load7ZipLibrary()
{
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Environment.Is64BitProcess ? "7z64.dll" : "7z86.dll");
if (!File.Exists(path))
{
    path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Bin", Environment.Is64BitProcess ? "7z64.dll" : "7z86.dll");
}
if (!File.Exists(path))
{
    throw new FileNotFoundException("Could not find native SevenZipLib.", path);
}
SafeLibraryHandle handle = LoadLibrary(path);
if (handle.IsInvalid)
{
    throw new Win32Exception(Marshal.GetLastWin32Error(), "Unable to load 7-Zip library.");
}
return handle;
}

comments