Skip to content

The entry point "git_libgit2_init" was not found in the DLL "git2-a418d9d" #2126

Open
@0Floppy0

Description

@0Floppy0

Hi,

I try to use LibGit2Sharp within my .NetFw 4.8 Project and stuck with an error when trying to use the lib.

It seems to not be able to load/read from the NativeLibaries file correctly.

Reproduction steps:

Add nuget-Packages to your project:

<package id="LibGit2Sharp" version="0.30.0" />
<package id="LibGit2Sharp.NativeBinaries" version="2.0.322" />

Build will create files in the output directory as expected "/lib/win32/x64/git2-a418d9d.dll"

Call Any Method. For example: Repository.Clone(pullurl, workingdir);

Expected behavior:

Execute of "clone" command sucessfully finished.

Actual behavior:

The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.

The Stacktrace:
Unexpected exception occurred: System.TypeInitializationException: The type initializer for "LibGit2Sharp.Core.NativeMethods" threw an exception. ---> System.EntryPointNotFoundException: The entry point "git_libgit2_init" was not found in the DLL "git2-a418d9d". at LibGit2Sharp.Core.NativeMethods.git_libgit2_init() at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary()...

Version of LibGit2Sharp
0.30.0

Version of NativeBinaries
2.0.322

OS: Windows 10 based
.NetFW: 4.8 C#7 (SDK 6 & 8 installed)

Activity

bording

bording commented on Nov 7, 2024

@bording
Member

I've just tried using the latest packages with a net48 project and it works fine, so there must be something else going on.

If you can provide me with a sample application that reproduces the problem, I can take another look at it.

0Floppy0

0Floppy0 commented on Nov 8, 2024

@0Floppy0
Author

[lib2git_debug.zip]
Thank you for the quick response. Thats what i was afraid of, that its a "my side only" issue. On my side i get the issue even when calling Repository.Init.

I added a simple sample. The proj conf is 1:1 to my real code but configured as a consoleApp instead of a assembly only.

its net48, c#7

bording

bording commented on Nov 8, 2024

@bording
Member

The project as you zipped it up does not compile.

I was able to make it work by fixing up the NuGet package locations in the project file, and after doing so, the project compiled and ran just fine on my machine.

If I had to take a wild guess (and at this point that's all I can really do), it seems like you've got a corrupted version of the libgit2 binaries.

ethomson

ethomson commented on Nov 8, 2024

@ethomson
Member

If I had to take a wild guess (and at this point that's all I can really do), it seems like you've got a corrupted version of the libgit2 binaries.

Or you're using Windows on ARM?

bording

bording commented on Nov 8, 2024

@bording
Member

Or you're using Windows on ARM?

Only if it's arm32:

image

ethomson

ethomson commented on Nov 8, 2024

@ethomson
Member

Ah, interesting.

0Floppy0

0Floppy0 commented on Nov 11, 2024

@0Floppy0
Author

i will check if i find a way to check if the binaries are fine. No i use Winx64 not ARM.

cbarkinozer-softtech

cbarkinozer-softtech commented on Mar 21, 2025

@cbarkinozer-softtech

I am having the same problem with winx64, trying to build visual studio extension. I am trying to get git diff. LibGit2Sharp.Core.NativeMethods' threw an exception. git2-****.dll not found.

0Floppy0

0Floppy0 commented on Mar 21, 2025

@0Floppy0
Author

@cbarkinozer-softtech I didn't investeigate any further and used gitbash over CLI instead.

Nevertheless i would be interested If you find a reason/solution

cbarkinozer-softtech

cbarkinozer-softtech commented on Mar 28, 2025

@cbarkinozer-softtech

Hey @0Floppy0 , yeah it got solved when we downloaded that dll and put it under the "C:\Windows\System32" folder. It is interesting that the solution was not inside the project :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bording@ethomson@0Floppy0@cbarkinozer-softtech

        Issue actions

          The entry point "git_libgit2_init" was not found in the DLL "git2-a418d9d" · Issue #2126 · libgit2/libgit2sharp