libgit2 / libgit2/libgit2sharp

Unable to load DLL 'git2'

Đang mở
#1,656 6 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
C#
Star
3.5k
Fork
925
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu từ phần khởi tạo NativeMethods được hiển thị trong stack trace và tái hiện thiết lập VS 2017 thủ công với git2 DLL đã được đổi tên. Một hướng giải quyết hữu ích sẽ xác định liệu LibGit2Sharp có hỗ trợ tải tệp nhị phân đã được đổi tên bên ngoài đó hay không, hoặc làm rõ cách triển khai được hỗ trợ, sau đó xác minh rằng lệnh gọi Clone không còn phát sinh DllNotFoundException.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
csharp
Lĩnh vực
devtools
Loại issue
Lỗi
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
20/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.