diff --git a/src/libraries/Common/src/Interop/Interop.Ldap.cs b/src/libraries/Common/src/Interop/Interop.Ldap.cs index d933cf98f2ed1c..0fbb469302b8ba 100644 --- a/src/libraries/Common/src/Interop/Interop.Ldap.cs +++ b/src/libraries/Common/src/Interop/Interop.Ldap.cs @@ -268,7 +268,7 @@ public void Free() {} } } #else - public static readonly unsafe int Size = Marshal.SizeOf(); + public static readonly unsafe int Size = sizeof(LdapReferralCallback); #endif } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupSids.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupSids.cs index 24abe5323e5bd4..305cbdfd250f1c 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupSids.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupSids.cs @@ -27,7 +27,7 @@ public static unsafe void InitializeReferencedDomainsList(this SafeLsaMemoryHand // We don't know the real size of the referenced domains yet, so we need to set an initial // size based on the LSA_REFERENCED_DOMAIN_LIST structure, then resize it to include all of // the domains. - referencedDomains.Initialize((uint)Marshal.SizeOf()); + referencedDomains.Initialize((ulong)sizeof(Interop.LSA_REFERENCED_DOMAIN_LIST)); Interop.LSA_REFERENCED_DOMAIN_LIST domainList = referencedDomains.Read(0); byte* pRdl = null; diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/Interop/LdapPal.Linux.cs b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/Interop/LdapPal.Linux.cs index 15b3cd86effafb..ab965f9fefaab6 100644 --- a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/Interop/LdapPal.Linux.cs +++ b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/Interop/LdapPal.Linux.cs @@ -226,7 +226,7 @@ internal static int SaslInteractionProcedure(IntPtr ldapHandle, uint flags, IntP // Move to next interact challenge Marshal.StructureToPtr(interactChallenge, currentInteractPtr, false); - currentInteractPtr = IntPtr.Add(currentInteractPtr, Marshal.SizeOf()); + currentInteractPtr = IntPtr.Add(currentInteractPtr, sizeof(SaslInteractiveChallenge)); interactChallenge = Marshal.PtrToStructure(currentInteractPtr); }