Re: End of Stream encountered before parsing was completed

Tech-Archive recommends: Speed Up your PC by fixing your registry



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 [.NET/C# MVP]" wrote:

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]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"Guru" <Guru@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C682100E-FC37-4070-93F4-0AB879C2D3B4@xxxxxxxxxxxxxxxx
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



.



Relevant Pages

  • Re: serialization shared memory problem
    ... If you serialize in one app, and want to deserialize in another app, an ... register the serializing app in the GAC. ... when setting your BinaryFormatter up to deserialize, ... The exception that I'm ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: reading in C++ a binary serialized object from .net
    ... serializing and de-serializing various data at the site ... > a binary stream coming from a .net object standard serialization. ... > MyObject obj = new MyObject; ... > IFormatter formatter = new BinaryFormatter(); ...
    (microsoft.public.dotnet.framework.interop)
  • Re: SerlializationException
    ... then retrieving them afterwards. ... Serializing and storing the objects seems to ... What is really puzzling me is that I ran a test and when I deserialize ... the objects immediately (that is, I don't store them to the database, I ...
    (microsoft.public.dotnet.languages.vb)
  • Re: reading in C++ a serialized object from .net
    ... For example,> let's assume I have a .net client which serializes some "POD" objects> using the standard .net serialization mechanism, then writes them to a> network stream, and finally a C++ server receives this stream, reads ... > - any kind of specification of the .net binary format used when> serializing objects? ... > MyObject obj = new MyObject; ...
    (microsoft.public.dotnet.general)
  • Re: Serialize A Dictionary
    ... I would like to pass my stream in a URL. ... >> I am thinking that I might have to roll my own very lightweight class. ... >>> Andrew, ... Yes, you are serializing the entire object, which means ...
    (microsoft.public.dotnet.languages.csharp)