Skip to content

Commit

Permalink
Add RID-specific runtime folder load fallback (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
Scottj1s authored May 29, 2020
1 parent 46da6c0 commit bef0663
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cswinrt/strings/WinRT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@ public static DllModule Load(string fileName)
// Explicitly look for module in the same directory as this one, and
// use altered search path to ensure any dependencies in the same directory are found.
_moduleHandle = Platform.LoadLibraryExW(System.IO.Path.Combine(_currentModuleDirectory, fileName), IntPtr.Zero, /* LOAD_WITH_ALTERED_SEARCH_PATH */ 8);
#if !NETSTANDARD2_0
if (_moduleHandle == IntPtr.Zero)
{
try
{
// Allow runtime to find module in RID-specific relative subfolder
_moduleHandle = NativeLibrary.Load(fileName, Assembly.GetExecutingAssembly(), null);
}
catch (Exception) { }
}
#endif
if (_moduleHandle == IntPtr.Zero)
{
Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
Expand Down

0 comments on commit bef0663

Please sign in to comment.