Protobuf-net - 流不支持并发IO读写操作

Protobuf-net - The stream does not support concurrent IO read or write operations

我在 VB.Net(v2.0 框架)中有一个程序,在从 sql 数据 reader 执行 http post 时,出现以下错误在几台机器上:

System.NotSupportedException: The stream does not support concurrent IO read or write operations.
   at System.Net.ConnectStream.InternalWrite(Boolean async, Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)
   at System.Net.ConnectStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at ProtoBuf.ProtoWriter.Flush(ProtoWriter writer)
   at ProtoBuf.ProtoWriter.Dispose()
   at ProtoBuf.ProtoWriter.System.IDisposable.Dispose()
   at ProtoBuf.Meta.TypeModel.SerializeWithLengthPrefix(Stream dest, Object value, Type type, PrefixStyle style, Int32 fieldNumber, SerializationContext context)
   at ProtoBuf.Serializer.SerializeWithLengthPrefix[T](Stream destination, T instance, PrefixStyle style, Int32 fieldNumber)
   at ProtoBuf.Serializer.SerializeWithLengthPrefix[T](Stream destination, T instance, PrefixStyle style)

代码:

    postStream = request.GetRequestStream()
        While dr.Read()
           dd.Add(dr) ' Adding data row to proto
           ProtoBuf.Serializer.SerializeWithLengthPrefix(Of DataDump)(postStream, dd, ProtoBuf.PrefixStyle.Base128) ' stream proto to http post stream
           dd.Clear() ' Clear proto 
        End While
 response = DirectCast(request.GetResponse(), HttpWebResponse)

Protobuf-net 不会发出 并发读取或写入操作。既然你提到了请求流,我预计实际问题与 this question.

有关

归根结底,这根本不是protbuf-net相关的问题。即使在将原型保存在二进制文件中然后尝试上传之后,它也会抛出错误。 它可能是 httpwebrequest、.net 或 windows 补丁或 sophos 杀毒软件。 我正在关闭这个问题,因为它已经进入了不同的切线。 感谢您的帮助。