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
Jesse Houwing - 17 Feb 2008 17:51 GMT
Hello Mugunth,
> Is there any special advantage of using Serialization using a
> BinaryFormatter over classic Read/Write using BinaryReader and
[quoted text clipped - 4 lines]
> 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.
--
Jesse Houwing
jesse.houwing at sogeti.nl