-
Notifications
You must be signed in to change notification settings - Fork 897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NativeMethods.ResolveDll: Avoid exceptions #1741
Conversation
This is now on nuget.org as 0.27.0-preview-0034. |
@bording Awesome, thanks! |
Can this be either a) implemented in the 0.26 maintenance branch and released to Nuget as |
Given the other work going on to try to improve the overall native binary scenario, I don't think we're at a point where we'd want to do another non-preview release yet. |
The prerelease version should be able to handle missing dlls better than the official release based on libgit2/libgit2sharp#1741
commit d36a0a6ede6f257b1bc2b518ba82c61888ede219 Author: Timo Wolters <[email protected]> Date: Thu Aug 12 14:14:12 2021 +0200 Update FileConfigurationStorage.cs The default configuration will be returned instead of throwing an exception. This should help make the application more resilient during startup. commit deabce5 Author: Timo Wolters <[email protected]> Date: Thu Aug 12 13:44:19 2021 +0200 Updating to LibGit2Sharp Prelease The prerelease version should be able to handle missing dlls better than the official release based on libgit2/libgit2sharp#1741 commit 98808bc Author: Timo Wolters <[email protected]> Date: Thu Aug 12 12:59:09 2021 +0200 Fixed issues with failing integration tests. Enabled integration tests in Github Actions again. Bugfix: Integration tests will no longer execute in parallel to avoid accessing shared resources. Bugfix: Fixed an issue with misleading messages during initial setup.
On .NET Core 3.0, LibGit2Sharp registers a per-assembly resolver using via
NativeLibrary.SetDllImportResolver
.The per-assembly resolver is the first attempt to resolve native library loads initiated by an assembly and takes precedence over other mechanisms, such as
AssemblyLoadContext
.The current implementation throws an exception if the
{assemblyDirectory}/runtimes
directory does not exist. In that case, the native load mechanism aborts, andAssemblyLoadContext
never gets a chance to locate the native library.This PR adds a
Directory.Exists
check to avoid that exception.ResolveDll
will returnIntPtr.Zero
, and theAssemblyLoadContext
is invoked next.