Home All Groups Group Topic Archive Search About

List<MyStruct> serialization problem (.Net 2.0)

Author
27 Oct 2006 6:09 AM
thomas
Hello,

Probably I am mission something obvious, but here is the problem:
I have a very simple structure (struct)  with a read/write public property.
Then, I serialize and deserialize generics List of my simple structure -
actually ASP.Net does it inside the HttpSessionState object.
The problem is that my public read/write property does not get preserved
between calls - I guess it simply does not get serialized. Read-only
properties I set through the constructor get serialized as expected.

Now, the interesting part: if I convert my structure to a class everything
works as expected.
Is it a standard behavior? Is this problem ASP.Net related? - may be it
simply does not check if changes to value types were made and skips
serialization as a part of its optimization algorithm? Can it be changed? -
I would prefer using structures (value types) than classes.

Tomasz

AddThis Social Bookmark Button