
Signature
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.
EmailID = varnk
Domain = Diebold.com
-----------------------------------
Hi Ken!
> I am writing a structure marked as serializable to a data file using
> the BinaryFormatter. The structure does not inherit from any other
[quoted text clipped - 5 lines]
> Can someone explain why the resulting size of the written data is so
> large?
As Vadym pointed out, the metadata serialization takes some space.
> Is there anyway to trim down the size of data written to be more
> efficient with the storage during serialization?
You can implement ISerializable. Within the GetObjectData() method, you
perform a custom serialization (maybe with minimal metadata - or even no
metadata when you know the size and the position of all elements) within a
byte - Array. This byte Array you can add to the SerializationInfo object in
one call.
Even if the .Net Infrastructure adds metadata for the byte-Array, it is much
smaller!
GP
Ken Varn - 03 Nov 2006 17:10 GMT
I tried implementing ISerializable in my class, but still yield about the
same size. How do you reduce the amount of data that the Serialization
object provides?
I have a StructLayout attribute on my class and thought that maybe I could
somehow tie that into serialization in a similar way it is used for
marshalling, but that is not available.

Signature
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.
EmailID = varnk
Domain = Diebold.com
-----------------------------------
Hi Ken!
> I am writing a structure marked as serializable to a data file using
> the BinaryFormatter. The structure does not inherit from any other
[quoted text clipped - 5 lines]
> Can someone explain why the resulting size of the written data is so
> large?
As Vadym pointed out, the metadata serialization takes some space.
> Is there anyway to trim down the size of data written to be more
> efficient with the storage during serialization?
You can implement ISerializable. Within the GetObjectData() method, you
perform a custom serialization (maybe with minimal metadata - or even no
metadata when you know the size and the position of all elements) within a
byte - Array. This byte Array you can add to the SerializationInfo object in
one call.
Even if the .Net Infrastructure adds metadata for the byte-Array, it is much
smaller!
GP