diff --git a/src/MongoDB.Driver/Core/Connections/BinaryConnection.cs b/src/MongoDB.Driver/Core/Connections/BinaryConnection.cs index a775f7dff0d..3359a33821e 100644 --- a/src/MongoDB.Driver/Core/Connections/BinaryConnection.cs +++ b/src/MongoDB.Driver/Core/Connections/BinaryConnection.cs @@ -463,7 +463,7 @@ public async Task ReceiveMessageAsync( private int GetResponseTo(IByteBuffer message) { var backingBytes = message.AccessBackingBytes(8); - return BitConverter.ToInt32(backingBytes.Array, backingBytes.Offset); + return BinaryPrimitives.ReadInt32LittleEndian(backingBytes.Array.AsSpan().Slice(backingBytes.Offset, 4)); } private void SendBuffer(OperationContext operationContext, IByteBuffer buffer)