libgit2 / libgit2/libgit2sharp

Unable to load DLL 'git2'

Abierto
#1,656 6 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
C#
Estrellas
3.5k
Forks
925
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

Hi All,

I know there are a number of similar issues listed, but non quite fit my scenario.

I have a system (that I cant change) that stores code and dlls (binary blob) in a database. The data is extracted and a VS Solution is generated. As such I do not have the ability to use NuGet or to force the git2-4aecb64.dll into the specific folders required for it to work.
Additionally the git2.dll is renamed (also out of my control) with a UID on the end.
eg. git2-4aecb64_Server_c8l_S0Kakc7Do5PhhDGPhxoObuMgSRw2detcnbwdOuQ.dll

So, based on other incidents raised, I understandably get the following error when the git-xxx.dll is included in the root folder next to LibGit2Sharp.dll

System.Web.Services.Protocols.SoapException: Server was unable to process request.
---> System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. --->
System.DllNotFoundException: Unable to load DLL 'git2-4aecb64': The specified module could not be found. (Exception from HRESULT: 0x8007007E)at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()at LibGit2Sharp.Core.NativeMethods.LibraryLifetimeObject..ctor()at LibGit2Sharp.Core.NativeMethods..cctor()
--- End of inner exception stack trace ---

Does anyone have any suggestions for resolving this?

Possibly a config item I can pass to LibGit2Sharp that would take a relative path to the git2.dll?

Or could I build a combined DLL?

Reproduction steps
  1. Create new VS 2017 c# console app
  2. Manually add Reference to LibGit2Sharp.dll and then copy git2-4aecb64.dll to the bin folder
  3. Try to Clone a Repository using below code
var cloneOptions = new CloneOptions { BranchName = "master", Checkout = true };
cloneOptions.CredentialsProvider = (_url, _user, _cred) => new UsernamePasswordCredentials { Username = username, Password = pass };
string localFolder = @"C:\Repos\test"; 
var cloneResult = LibGit2Sharp.Repository.Clone(url, localFolder, cloneOptions);
Expected behavior

Repository is cloned

Actual behavior

Exception is raised
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'git2-4aecb64': The specified module could not be found. (Exception from HRESULT: 0x8007007E)at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()at LibGit2Sharp.Core.NativeMethods.LibraryLifetimeObject..ctor()at LibGit2Sharp.Core.NativeMethods..cctor() --- End of inner exception stack trace ---

Version of LibGit2Sharp (release number or SHA1)

Versions pulled from NuGet package
LibGit2Sharp - version="0.25.4"
LibGit2Sharp.NativeBinaries - version="1.0.252"

Operating system(s) tested; .NET runtime tested

Windows 10 with .Net 4.7

Thanks,

Basil

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comience por la inicialización de NativeMethods mostrada en el stack trace y reproduzca la configuración manual de VS 2017 con la git2 DLL cuyo nombre se ha cambiado. Una resolución útil determinaría si LibGit2Sharp admite cargar ese binario renombrado externamente o aclararía la disposición de implementación compatible; después, verifique que la llamada a Clone ya no genere DllNotFoundException.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
csharp
Área
devtools
Tipo de issue
Error
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
20/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.