libgit2 / libgit2/libgit2sharp
Unable to load DLL 'git2'
还没有人认领这个 Issue。
- 主要语言
- C#
- 星标
- 3.5k
- 派生
- 925
- PR 合并指标
- 30 天内没有已合并 PR
描述
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
- Create new VS 2017 c# console app
- Manually add Reference to LibGit2Sharp.dll and then copy git2-4aecb64.dll to the bin folder
- 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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从堆栈跟踪中显示的 NativeMethods 初始化开始,使用已重命名的 git2 DLL 重现手动 VS 2017 设置。一个有用的解决方案应确定 LibGit2Sharp 是否支持加载那个外部重命名的二进制文件,或明确受支持的部署安排,然后验证 Clone 调用不再引发 DllNotFoundException。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp
- 领域
- devtools
- Issue 类型
- 缺陷
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 20/100