Skip to content

Commit

Permalink
fix: update ManagedLoadContext to search in additional probing paths (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Sewer56 authored Jan 31, 2021
1 parent f317c02 commit 5cd23e7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/Plugins/Loader/ManagedLoadContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,14 @@ public ManagedLoadContext(string mainAssemblyPath,
{
// if an assembly was not listed in the list of known assemblies,
// fallback to the load context base directory
var localFile = Path.Combine(_basePath, assemblyName.Name + ".dll");
if (File.Exists(localFile))
var dllName = assemblyName.Name + ".dll";
foreach (var probingPath in _additionalProbingPaths.Prepend(_basePath))
{
return LoadAssemblyFromFilePath(localFile);
var localFile = Path.Combine(probingPath, dllName);
if (File.Exists(localFile))
{
return LoadAssemblyFromFilePath(localFile);
}
}
}

Expand Down Expand Up @@ -225,17 +229,24 @@ protected override IntPtr LoadUnmanagedDll(string unmanagedDllName)
else
{
// fallback to native assets which match the file name in the plugin base directory
var localFile = Path.Combine(_basePath, prefix + unmanagedDllName + suffix);
if (File.Exists(localFile))
{
return LoadUnmanagedDllFromResolvedPath(localFile);
}
var prefixSuffixDllName = prefix + unmanagedDllName + suffix;
var prefixDllName = prefix + unmanagedDllName;

var localFileWithoutSuffix = Path.Combine(_basePath, prefix + unmanagedDllName);
if (File.Exists(localFileWithoutSuffix))
foreach (var probingPath in _additionalProbingPaths.Prepend(_basePath))
{
return LoadUnmanagedDllFromResolvedPath(localFileWithoutSuffix);
var localFile = Path.Combine(probingPath, prefixSuffixDllName);
if (File.Exists(localFile))
{
return LoadUnmanagedDllFromResolvedPath(localFile);
}

var localFileWithoutSuffix = Path.Combine(probingPath, prefixDllName);
if (File.Exists(localFileWithoutSuffix))
{
return LoadUnmanagedDllFromResolvedPath(localFileWithoutSuffix);
}
}

}
}

Expand Down
4 changes: 4 additions & 0 deletions src/Plugins/releasenotes.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<Project>
<PropertyGroup>
<PackageReleaseNotes Condition="'$(VersionPrefix)' == '1.4.0'">
Changes:
* @Sewer56 - search in additional probing paths (PR #172)
</PackageReleaseNotes>
<PackageReleaseNotes Condition="'$(VersionPrefix)' == '1.3.1'">
Changes:
* @KatoStoelen - don't create shadow copy that already exists (PR #147)
Expand Down

0 comments on commit 5cd23e7

Please sign in to comment.