Search code examples
androidxamarin.androidunzip7zipcompression

Issue with Uncompressing the .7z file in the Android evn


Getting "system.entrypointnotfoundexception: loadlibrary" While trying to use SevenZipLib.dll to uncompress the .7z file containing media contents/file in the Android evn.

Context: -The whole program is written in c# as a MONO Android Project. No Build/Deployment Error/warnings. While running the apk, its throwing "system.entrypointnotfoundexception: loadlibrary". -Also tested the same code as windows project (not mono) - uncompressing in the windows evn.

Assumptions for the issue: 7zip internally might be using COM components & Mono frame work is not supporting.

Question:

Has anyone come across similar issue? Please suggest some alternative dll/framework which can be used by my apk for uncompressing the .7z file.


Solution

  • Assuming that SevenZipLib.dll is the SevenZipLib Library on CodePlex, the problem is SevenZipLib\SevelZipLib\SevenZipArchive.cs:

    [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
    private static extern SafeLibraryHandle LoadLibrary(
      [MarshalAs(UnmanagedType.LPTStr)] string lpFileName);
    

    The project contains numerous P/Invokes into kernel32.dll (LoadLibrary(), GetProcAddress(), FreeLibrary()), ole32.dll (PropVariantClear()), oleaut32.dll (SafeArrayCreateVector()), and more.

    In short, this library is intimately tied to Windows, and isn't going to work on a non-Windows platform in any meaningful fashion, not without a lot of work.

    If you need 7z support in a Mono for Android application, you'll need to look into a different library. It looks like the 7-zip SDK includes C# source for reading LZMA files that doesn't rely on P/Invoke, so perhaps that would work?