Serialization vs Binary Read/Write

  • Thread starter Thread starter Mugunth
  • Start date Start date
M

Mugunth

Is there any special advantage of using Serialization using a
BinaryFormatter over classic Read/Write using BinaryReader and
BinaryWriter?
In my case, Serialization is bloating up the output file size
drastically at least by a factor of 5. Serialization also takes more
time (probably because of the huge size) that BinaryWriter.

Can someone elucidate the differences, advantages/disadvantages of one
over another?

Regards,
Mugunth
 
Hello Mugunth,
Is there any special advantage of using Serialization using a
BinaryFormatter over classic Read/Write using BinaryReader and
BinaryWriter?
In my case, Serialization is bloating up the output file size
drastically at least by a factor of 5. Serialization also takes more
time (probably because of the huge size) that BinaryWriter.
Can someone elucidate the differences, advantages/disadvantages of one
over another?

Serialization takes into account class versioning (if implemented in the
respective types), assembly names, public key tokens and such for each typereference
it encouters. This ofcourse makes the outptu larger, but also helps reading
the resulted binary back in in a later version of your application.

There are also a few serialization formatters available (for example those
used in the ASP.NET Viewstate serialization process) that are specifically
created to make the output as small as possible. You could have a look at
those. One is called the LosFormatter and there's a nice post available here:

http://rahulgangwar.spaces.live.com/blog/cns!EC27D61C72887359!137.entry

That explains it pretty well.
 

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