Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems loading git2.dll?

Im trying to use the libgit2sharp library. My only code is

Repository repository = new Repository(@"C:\Path\To\Repo");

and when i run it i get an error saying Unable to load DLL 'git2': The specified module could not be found. So, I manually went and grabbed the git2.dll from libgit2sharp and moved it into the directory. When running the same program after that I get another error: An attempt was made to load a program with an incorrect format.

While researching this I found this post and the solution that seemed to work for the poster there didnt work for me. That post was also made a year ago and a supposed fix was made for it, Im using the latest branch of libgit2sharp (ive tried older repositories no change)

Any ideas?

like image 917
Whyrusleeping Avatar asked Nov 04 '22 20:11

Whyrusleeping


1 Answers

The recommended option would be to install the latest LibGit2Sharp NuGet package which will take care of installing everything in the correct location.

However, if you prefer to handle this by hand, the GitHub repository includes both x86 and amd64 version of the git2.dll. Performing a checkout of the master or vNext branch should retrieve them.

Beware that every version of LibGit2Sharp works against a specific version of the libgit2 binary. Each LibGit2Sharp branch contains a libgit2 submodule which points at the libgit2 commit being wrapped.

submodule

In order for it to perfectly work, the LibGit2Sharp assembly expects the git2.dll binary to be located into a specific tree structure.

LibGit2Sharp.dll
|__NativeBinaries
   |__x86
   |  |_git2.dll
   |
   |__amd64
      |_git2.dll
like image 72
nulltoken Avatar answered Nov 14 '22 23:11

nulltoken