Skip to content

Commit

Permalink
Avoid exception is static ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
sakno committed Jan 13, 2024
1 parent 69afdb1 commit 1768c0d
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>(getpwuid)
: null;
}
Expand Down

0 comments on commit 1768c0d

Please sign in to comment.