Search code examples
c#monolibgit2libgit2sharp

not able to run LibGit2Sharp on Mono on ubuntu


have a very simple one line console app (using monodevelop)

but getting below error.

System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: git2-e0902fb

my app has reference two nuget package

  • LibGit2Sharp 0.21.0.176
  • LibGit2Sharp.NativeBinaries 1.0.119

LibGit2Sharp.Repository.Init("foler path");

enter image description here

enter image description here


Solution

  • libGit2Sharp 0.21.0.176 nuget does have dependency on a specific native library and it requires 'version/sha' e0902fb and that is not included in the 1.0.119 or 1.0.106 native nugets. (I always build these packages from source.)

    The pre-release nuget for LibGit2Sharp 0.22.0-pre20151023210959 does include a native nuget dependency and pulls 1.0.6 version of the LibGit2Sharp.NativeBinaries which work together.

    So:

    Either use the pre-release version of LibGit2Sharp and it will pull in the 1.0.6 version of LibGit2Sharp.NativeBinaries which provides the correct 64-bit shared library (libgit2-6aa06b6.so) that work together:

    <?xml version="1.0" encoding="utf-8"?>
    <packages>## Heading ##
      <package id="LibGit2Sharp" version="0.22.0-pre20151023210959" targetFramework="net45" />
      <package id="LibGit2Sharp.NativeBinaries" version="1.0.106" targetFramework="net45" />
    </packages>
    

    Or:

    Use the release version of LibGit2Sharp (0.21.0.176) and find if a Native Nuget is available(?) with a 64-bit linux-based libgit2-e0902fb.so.

    Or:

    Use the release version of LibGit2Sharp (0.21.0.176) and build the native lib from source.