From 1768c0dd961c908ba068771343e6fd9816399352 Mon Sep 17 00:00:00 2001 From: sakno Date: Sat, 13 Jan 2024 21:50:31 +0200 Subject: [PATCH] Avoid exception is static ctor --- .../Security/Principal/LinuxUdsPeerIdentity.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/DotNext.MaintenanceServices/Security/Principal/LinuxUdsPeerIdentity.cs b/src/DotNext.MaintenanceServices/Security/Principal/LinuxUdsPeerIdentity.cs index 1290ca474..0d0ccdfd7 100644 --- a/src/DotNext.MaintenanceServices/Security/Principal/LinuxUdsPeerIdentity.cs +++ b/src/DotNext.MaintenanceServices/Security/Principal/LinuxUdsPeerIdentity.cs @@ -18,8 +18,7 @@ public sealed record class LinuxUdsPeerIdentity : IIdentity static LinuxUdsPeerIdentity() { - var getpwuid = NativeLibrary.GetExport(NativeLibrary.GetMainProgramHandle(), "getpwuid"); - GetpwuidFunction = getpwuid is not 0 + GetpwuidFunction = NativeLibrary.TryGetExport(NativeLibrary.GetMainProgramHandle(), "getpwuid", out var getpwuid) ? Marshal.GetDelegateForFunctionPointer(getpwuid) : null; }