From 9bce747be745e5292eff660e8974f22f30310690 Mon Sep 17 00:00:00 2001 From: Danny Rorabaugh Date: Tue, 25 Jun 2024 17:37:08 -0400 Subject: [PATCH] Don't use dlerror when not available --- source/icu.net/NativeMethods/NativeMethods.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/icu.net/NativeMethods/NativeMethods.cs b/source/icu.net/NativeMethods/NativeMethods.cs index 4a2e141b..3d091fb5 100644 --- a/source/icu.net/NativeMethods/NativeMethods.cs +++ b/source/icu.net/NativeMethods/NativeMethods.cs @@ -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;