Skip to content

Commit

Permalink
Don't use dlerror when not available
Browse files Browse the repository at this point in the history
  • Loading branch information
imnasnainaec authored and jasonleenaylor committed Jun 26, 2024
1 parent ef19bf9 commit 9bce747
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions source/icu.net/NativeMethods/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,17 @@ private static IntPtr GetIcuLibHandle(string basename, int icuVersion)
}

lastError = Marshal.GetLastWin32Error();
#if NET6_0_OR_GREATER
var errorMsg = IsWindows
? new Win32Exception(lastError).Message
: $"{lastError}";
#else
var errorMsg = IsWindows
? new Win32Exception(lastError).Message
: IsMac
? $"{lastError}"
: $"{lastError} ({dlerror()})";
#endif
Trace.WriteLineIf(lastError != 0, $"Unable to load [{libPath}]. Error: {errorMsg}");
Trace.TraceWarning($"{loadMethod} of {libPath} failed with error {errorMsg}");
icuVersion -= 1;
Expand Down

0 comments on commit 9bce747

Please sign in to comment.