End of Stream encountered before parsing was completed

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all

I've serializing an object to a Network stream but when trying to
deserialize
it comes back with
"End of Stream encountered before parsing was completed."

Using Binary formatter to send across.

Any idea how to solve this.
Thanks in advance.
Guru
 
Guru,

It's very possible that the stream is closed for some reason (network
problems) before deserialization completes.

If you want to be sure, you should send some sort of length prefix
before the serialized object stream. Then, read the bytes into a local
buffer, then deserialize from that.

Hope this helps.
 
Hi Nicholas

First Thanks for your reply...

Can you elloborate on code level. B'coz I am serializing the object(Object
o). So how to find the length and send it back?

Please give me some pointer.
My code is like :-

Serilizing:
-----------
IFormatter m_formatter;
NetworkStream n_stream;
.....
...
m_formatter.Serialize(n_stream,o);
....
....


Deserializing on TCP client:
------------------------------
....
....
Object o = m_formatter.Deserialize(n_stream);
.........

So any idea??
Thanks in advance..
Guru

Nicholas Paldino said:
Guru,

It's very possible that the stream is closed for some reason (network
problems) before deserialization completes.

If you want to be sure, you should send some sort of length prefix
before the serialized object stream. Then, read the bytes into a local
buffer, then deserialize from that.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Guru said:
Hi all

I've serializing an object to a Network stream but when trying to
deserialize
it comes back with
"End of Stream encountered before parsing was completed."

Using Binary formatter to send across.

Any idea how to solve this.
Thanks in advance.
Guru
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top