Open fbehrens opened 6 years ago
I'm not familiar with the F# Interactive interpreter, but a number of people have used LibGit2Sharp from an F# application. I suspect that the F# Interactive interpreter is not setting things up nicely.
Can you debug to see where it's trying to load the native library from?
Thanks for the feedback. Yes, when I compile it is working fine.
Below are the details of the exception I got when I run above code fsi
. Not sure if that helps
Message "The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception." string
at LibGit2Sharp.Core.NativeMethods.git_repository_open(git_repository*& repository, FilePath path)
at LibGit2Sharp.Core.Proxy.git_repository_open(String path)
at LibGit2Sharp.Repository..ctor(String path, RepositoryOptions options, RepositoryRequiredParameter requiredParameter)
at <StartupCode$FSI_0003>.$FSI_0003.main@() in D:\\scripts2dev\\libwba\\src\\LibGit\\LibGit2Sharp.fsx:line 3" string
Inner Exception:
Message "Unable to load DLL 'git2-b0d9952': The specified module could not be found. (Exception from HRESULT: 0x8007007E)" string
at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary()
at LibGit2Sharp.Core.NativeMethods..cctor()"
@ethomson I get this issue with 1.0.226 in C# when using NUnit. But not in 1.0.210 (i have not tried 1.0.117). Could there be a bug? Also cannot load the dll manually, but i can with 210...
at LibGit2Sharp.Core.NativeMethods.git_libgit2_init () atLibGit2Sharp.Core.NativeMethods.LoadNativeLibrary () In LibGit2Sharp.Core.NativeMethods. Cctor () ---the end of the internal exception stack trace--- atLibGit2Sharp.Core.NativeMethods.git_buf_free (Gitbuf buf) atLibGit2Sharp.Core.Handles.GitBuf.Dispose () atLibGit2Sharp.Core.Proxy.ConvertPath (Func ' 2 pathretriever) atLibGit2Sharp.Core.Proxy.git_repository_discover (FilePath start_path) In LibGit2Sharp.Repository.Discover (String startingpath)
I managed to load the native dll via LoadLibrary of kernel32
See also https://christoph.ruegg.name/blog/loading-native-dlls-in-fsharp-interactive.html
[<DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)>]
extern IntPtr LoadLibrary(string lpFileName);
Reproduction steps
in a fresh fsi (using
ionide
) i can referenceLibGit2Sharp.dll
and open theLibGit2Sharp
namespace, but instantiating a Repository throws following error:And I can't reference the
dll
fromLibGit2Sharp.NativeBinaries
, because it throwsWhat am I missing? How can I use the compiled libraries ?
Expected behavior
It is possible to reference and use
LibGit2Sharp
infsi
Actual behavior
see above errors
Version of LibGit2Sharp (release number or SHA1)
So i am dowloading via
nuget LibGit2Sharp prerelease
in mypaket.dependencies
, which resolves toOperating system(s) tested; .NET runtime tested
this is on
Server 2016
withnet471
which should behave likewindows 10
.