【发布时间】:2015-01-17 04:26:34
【问题描述】:
我在 OSX 10.9.5 上使用 Xamarin Studio 5.7 和 Mono 3.12。使用 NuGet,我下载了 libgit2sharp 库。我可以在编写代码时使用这些类,没有编译器错误。但是在运行时出现以下错误:
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
它似乎在抱怨它找不到git2-91fa31f dll,但是当我查看包文件夹时,我可以看到该 dll 确实存在。
有没有人见过这个或者知道我可以做些什么来解决它?
更新
我按照@nulltoken 的说明下载了 libgit2 源代码。使用 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" .. 然后 cmake --build . 构建它
这产生了一个名为libgit2-91fa31f.dylib 的文件。我将此文件放在我的项目的exe所在的bin/Debug目录和LibGit2Sharp.dll所在的目录中。但是现在当我运行程序时,我得到以下信息:
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
我感觉我搞砸了 cmake 部分。对吗?
【问题讨论】:
标签: c# mono libgit2sharp