I am using Xamarin Studio 5.7 with Mono 3.12 on OSX 10.9.5. Using NuGet I downloaded the libgit2sharp library. I am able to use the classes when writing the code, there are no compiler errors. However at run time I get the following error:
Unhandled Exception:
System.TypeInitializationException: An exception was thrown by the type initializer for LibGit2Sharp.Core.NativeMethods ---> System.DllNotFoundException: git2-91fa31f
at (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods:git_threads_init ()
at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject..ctor () [0x00000] in <filename unknown>:0
at LibGit2Sharp.Core.NativeMethods..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at LibGit2Sharp.Core.Proxy.git_repository_open (System.String path) [0x00000] in <filename unknown>:0
at LibGit2Sharp.Repository..ctor (System.String path, LibGit2Sharp.RepositoryOptions options) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for LibGit2Sharp.Core.NativeMethods ---> System.DllNotFoundException: git2-91fa31f
at (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods:git_threads_init ()
at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject..ctor () [0x00000] in <filename unknown>:0
at LibGit2Sharp.Core.NativeMethods..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at LibGit2Sharp.Core.Proxy.git_repository_open (System.String path) [0x00000] in <filename unknown>:0
at LibGit2Sharp.Repository..ctor (System.String path, LibGit2Sharp.RepositoryOptions options) [0x00000] in <filename unknown>:0
It seems to be complaining that it cannot find the git2-91fa31f
dll but when I look in the packages folder I can see that that dll does exist.
Has anyone seen this before or know what I can do to fix it?
UPDATE
I followed @nulltoken's instructions and downloaded the libgit2 source. Built it using cmake -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo -DBUILD_CLAR:BOOL=OFF -DUSE_SSH=OFF -DENABLE_TRACE=ON -DLIBGIT2_FILENAME=git2-91fa31f -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" ..
then cmake --build .
This produced a file called libgit2-91fa31f.dylib
. I placed this file in the bin/Debug
directory where the exe of my project is and where LibGit2Sharp.dll
is. However now when I run the program I get the following:
Unhandled Exception:
System.TypeInitializationException: An exception was thrown by the type initializer for LibGit2Sharp.Core.NativeMethods ---> System.EntryPointNotFoundException: git_threads_init
at (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods:git_threads_init ()
at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject..ctor () [0x00000] in <filename unknown>:0
at LibGit2Sharp.Core.NativeMethods..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at LibGit2Sharp.Core.Proxy.git_repository_open (System.String path) [0x00000] in <filename unknown>:0
at LibGit2Sharp.Repository..ctor (System.String path, LibGit2Sharp.RepositoryOptions options) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for LibGit2Sharp.Core.NativeMethods ---> System.EntryPointNotFoundException: git_threads_init
at (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods:git_threads_init ()
at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject..ctor () [0x00000] in <filename unknown>:0
at LibGit2Sharp.Core.NativeMethods..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at LibGit2Sharp.Core.Proxy.git_repository_open (System.String path) [0x00000] in <filename unknown>:0
at LibGit2Sharp.Repository..ctor (System.String path, LibGit2Sharp.RepositoryOptions options) [0x00000] in <filename unknown>:0
I have a feeling I messed up the cmake part. Is that correct?