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;