Home All Groups Group Topic Archive Search About

BinaryFormatter produce larger file after ISerializable implemente

Author
9 Mar 2006 10:59 AM
Slava
Question about serialization to binary format under .Net 1.1 using C#.

I have some set of classes, some of them are marked with
SerializableAttribute. I use serialization to binary files to persist some
object graph between app sessions.

I've made an easy change to my code: each class which is marked as
Serializable implements ISerializable i-face now, and contains
deserialization ctor. The GetObjectData method is implemented very easy: each
field that was serialized automatically is added to SerializationInfo now by
call to AddValue.

Now, what is my problem. If I serialize an object graph to file by
BinaryFormatter using new classes version (ISerializable) I got a larger file
(about 2 times) that before.

Why??

Author
9 Mar 2006 6:15 PM
Slava
It looks like the problem is because of serialization of descendants of
abstract classes, but I'm not sure.

Any ideas?
Author
9 Mar 2006 8:26 PM
Robert Hooker
Woohoo!! Someone else noticed my favorite problem!

See this thread:
http://groups.google.com/group/microsoft.public.dotnet.framework/browse_frm/thread/2615e1f489e7a916/c94132480ff4eeb2?tvc=1&q=group%3A*dotnet*+author%3AHooker&hl=en#c94132480ff4eeb2

For a detailed - and sometimes painful - history.

The short answer to your question (and it isn't really an answer) was given
at the end of the chain:

****************
AFAIK, the builtin serialization will optimize for better performance under
certain circumstances. While for custom serialization, it has to strictly
follow the ISerializable.GetObjectData() you provided to repeat an extra
100 times of "SerializationTest.ChildNode??val1?parent?subNode" as in this
case.
****************

Cheers,
Rob


Show quote
"Slava" <Sl***@discussions.microsoft.com> wrote in message
news:F6CC5B78-B177-4D72-9E20-81B1CF845585@microsoft.com...
> Question about serialization to binary format under .Net 1.1 using C#.
>
> I have some set of classes, some of them are marked with
> SerializableAttribute. I use serialization to binary files to persist some
> object graph between app sessions.
>
> I've made an easy change to my code: each class which is marked as
> Serializable implements ISerializable i-face now, and contains
> deserialization ctor. The GetObjectData method is implemented very easy:
> each
> field that was serialized automatically is added to SerializationInfo now
> by
> call to AddValue.
>
> Now, what is my problem. If I serialize an object graph to file by
> BinaryFormatter using new classes version (ISerializable) I got a larger
> file
> (about 2 times) that before.
>
> Why??
Author
10 Mar 2006 7:29 AM
Slava
And there is no new info about the issue since March 2004?

Show quote
AddThis Social Bookmark Button