本文是小编为大家收集整理的关于libgit2sharp dllnotfoundException:无法加载dll'git2-106a5f2'的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。
问题描述
我正在研究一个VSIX项目,我需要获取有关本地GIT目录的信息.我正在关注 a>文章.当我使用LibGit2Sharp库时,我将获得一个例外图像和错误所述: -
如何解决这个问题?
vs版本详细信息:
Visual Studio 2019
.NET框架4.7.2
推荐答案
libgit2sharp 是一种托管语言(.net)围绕(c)库中的托管语言(c) , libgit2 .这是一个 p/Invoke 层,再加上一层给出.NET语义(对象等).但是,这意味着您需要 libgit2sharp.dll(托管语言端)和 git2-xxxxxxx.dll(git2-xxxxxxx.dll(相应的本机库)).
本机dll是libgit2sharp依赖的libgit2sharp.nativebinaries项目的一部分.安装libgit2sharp本身时,应(传输)安装它.尽管它试图将自己设置为将安装在输出目录中的依赖项,但由于本机二进制文件在.NET Project World中并不理解,但有时可能会失败,尤其是对于更复杂的项目类型(例如VSIX)./p>
最终,libgit2sharp将在其所在的位置寻找相应的本机DLL.因此,在您的输出目录中,无论您从何处执行VSIX,尝试复制是Libgit2sharp.nativebinaries项目的git2-xxxxxxx.dll>
确定了git2-xxxxxxx.dll二进制生存的正确位置后,您应该将其复制为项目的安装一部分. (例如构建动作:无,复制到输出目录:始终复制)
其他推荐答案
我也有同样的问题,我这样解决了:
- 将dir文件夹从VisualStudioExtension -> Bin -> Debug -> lib复制到VisualStudioExtension项目的根.该文件夹包含Libgit2sharp工作所需的DLL文件.
- 将lib文件夹拖到Visual Studio中的VisualStudioExtension项目.
- 选择DLL文件,右键单击,属性,然后将其设置为始终复制并包含在VSIX中.
对我有用.
其他推荐答案
LibGit2Sharp对[Debug|Release]\lib\win32\[x86|[x64]目录下的git2-106a5f2.dll具有依赖性.
如果缺少该特定版本,则可能需要重新安装LibGit2Sharp库,但是卸载LibGit2Sharp.NativeBinaries卸载和安装之间的库.
Nuget软件包上的以下操作应有所帮助:
- 卸载LibGit2Sharp.
- 卸载LibGit2Sharp.NativeBinaries.
- 安装LibGit2Sharp.
注意:即使有较新的版本,也不要更新LibGit2Sharp.NativeBinaries
问题描述
I am working on a vsix project where I need to get information about a local git directory. I am following this article. When I am using LibGit2Sharp library, I am getting an exception as described in following image and error:-
How can I resolve this?
VS version details:
Visual Studio 2019
.Net Framework 4.7.2
推荐答案
LibGit2Sharp is a managed language (.NET) wrapper around a native (C) library, libgit2. It's a P/Invoke layer, plus a layer to give .NET semantics (objects, etc). This means, though, that you require both the LibGit2Sharp.dll (the managed-language side) and the git2-xxxxxxx.dll (the corresponding native library) that it calls into.
The native DLL is part of the LibGit2Sharp.NativeBinaries project that LibGit2Sharp takes a dependency on. It should be installed (transitively) when you install LibGit2Sharp itself. And although it tries to set itself up as a dependency that will be installed in the output directory, since native binaries are not well-understood in the .NET project world, this can sometimes fail, especially for more complex project types like VSIX.
Ultimately, LibGit2Sharp will look for the corresponding native DLL alongside where it's located. So within your output directory, wherever your VSIX is being executed from, try copying the git2-xxxxxxx.dll that is part of the LibGit2Sharp.NativeBinaries project to that location.
Once you've identified the correct location for the git2-xxxxxxx.dll binary to live, you should copy this as part of your installation for the project. (eg Build action: None, Copy to output directory: Copy always)
其他推荐答案
I had the same issue and I solved it like this:
- Copy the dir folder from VisualStudioExtension -> Bin -> Debug -> lib to the root of the VisualStudioExtension project. This folder contains the DLL files required for LibGit2Sharp to work.
- Drag the lib folder onto the VisualStudioExtension project in Visual Studio.
- Select the dll files, right-click, Properties, and set it to Copy always and include in VSIX.
That worked for me.
其他推荐答案
LibGit2Sharp has a dependency on the git2-106a5f2.dll which is under [Debug|Release]\lib\win32\[x86|[x64] directory.
If that particular version is missing, you may need to reinstall LibGit2Sharp library, but uninstall LibGit2Sharp.NativeBinaries library between uninstall and install.
The following operations on NuGet packages should help:
- Uninstall LibGit2Sharp.
- Uninstall LibGit2Sharp.NativeBinaries.
- Install LibGit2Sharp.
Note: do not update LibGit2Sharp.NativeBinaries even if there is a newer version.