Calling RawBsonDocument.ToBson sometimes results in an ArgumentOutOfRangeException, depending on the RawBsonDocument. A (partial) stack trace is
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: position at MongoDB.Bson.IO.ByteBufferSlice.EnsureValidPosition(Int32 position) in C:\Development\mongo-csharp-driver-2.2.1\mongo-csharp-driver-2.2.1\src\MongoDB.Bson\IO\ByteBufferSlice.cs:line 205 at MongoDB.Bson.IO.ByteBufferSlice.AccessBackingBytes(Int32 position) in C:\Development\mongo-csharp-driver-2.2.1\mongo-csharp-driver-2.2.1\src\MongoDB.Bson\IO\ByteBufferSlice.cs:line 114 at MongoDB.Bson.IO.BsonStreamExtensions.WriteSlice(BsonStream stream, IByteBuffer slice) in C:\Development\mongo-csharp-driver-2.2.1\mongo-csharp-driver-2.2.1\src\MongoDB.Bson\IO\BsonStreamExtensions.cs:line 311 at MongoDB.Bson.IO.BsonBinaryWriter.WriteRawBsonDocument(IByteBuffer slice) in C:\Development\mongo-csharp-driver-2.2.1\mongo-csharp-driver-2.2.1\src\MongoDB.Bson\IO\BsonBinaryWriter.cs:line 534 at MongoDB.Bson.Serialization.Serializers.BsonValueSerializerBase`1.Serialize(BsonSerializationContext context, BsonSerializationArgs args, TBsonValue value) in C:\Development\mongo-csharp-driver-2.2.1\mongo-csharp-driver-2.2.1\src\MongoDB.Bson\Serialization\Serializers\BsonValueSerializerBase.cs:line 80 at MongoDB.Bson.Serialization.Serializers.SerializerBase`1.MongoDB.Bson.Serialization.IBsonSerializer.Serialize(BsonSerializationContext context, BsonSerializationArgs args, Object value) in C:\Development\mongo-csharp-driver-2.2.1\mongo-csharp-driver-2.2.1\src\MongoDB.Bson\Serialization\Serializers\SerializerBase.cs:line 125 at MongoDB.Bson.BsonExtensionMethods.ToBson(Object obj, Type nominalType, BsonBinaryWriterSettings writerSettings, IBsonSerializer serializer, Action`1 configurator, BsonSerializationArgs args) in C:\Development\mongo-csharp-driver-2.2.1\mongo-csharp-driver-2.2.1\src\MongoDB.Bson\BsonExtensionMethods.cs:line 90 at MongoDB.Bson.BsonExtensionMethods.ToBson[TNominalType](TNominalType obj, IBsonSerializer`1 serializer, BsonBinaryWriterSettings writerSettings, Action`1 configurator, BsonSerializationArgs args) in C:\Development\mongo-csharp-driver-2.2.1\mongo-csharp-driver-2.2.1\src\MongoDB.Bson\BsonExtensionMethods.cs:line 46
At a glance it looks like the problem is in BsonStreamExtensions.WriteSlice, where position is being incremented incorrectly when the buffer has multiple chunks.