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

时间:2015-03-22 15:57:48

标签: vb.net memory httpwebrequest http-post protobuf-net

我在VB.Net(v2.0框架)中有一个程序,在从sql数据读取器执行http发布时,我在几台机器上收到以下错误:

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)

2 个答案:

答案 0 :(得分:2)

Protobuf-net 不会发出并发读取或写入操作。由于您提到请求流,我希望实际问题与this question相关。

答案 1 :(得分:0)

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