Serialization of Hashtable

  • Thread starter Thread starter Mark Smithson
  • Start date Start date
M

Mark Smithson

Hi,

I have noticed that when you serialize a Hashtable, a private variable named
"version" gets serialized. From what I can tell this variable keeps track of
additions to the hashtable and is used to ensure that items are not added or
removed during enumeration.

The problem I am having is that this variable causes the result of the
serialization of the Hashtable to be different every time you serialize it.
If you have a 2 item hashtable and serialize it, "value" is set to 2. If you
then deserialize the Hashtable and then serialize it again, the "value" will
be set to 4.

Does anyone have any insight as to why this variable needs to be serialised
with the Hashtable, or any ideas for excluding this from the serialization.
Ideas I have come up with myself are to manually serialise the Hashtable or
to try and "reset" this variable after serialization using Reflection.

Regards

Mark
 
Back
Top