Hi all,
What is the practical use of serialization?How it is used in development?
Thanks
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
ali razaPosted Nov 20, 2010, 3:53 AM
http://techgulf.blogspot.com/2010/11/viewstate-error-in-aspnet.html
Sam HobbsPosted Nov 16, 2010, 2:15 PM
Zoran HorvatPosted Nov 16, 2010, 11:10 AM
For example, if two instances of application communicate over socket by sending messages, message can be an instance of some class. Then you just fill object's properties with values you want to send to the remote instance, then serialize the object into XML and write it to socket. Remote application reads XML from the socket and deserializes it into object of message class. In that way, one appication instance has effectively sent an object to another application instance.
Similarly, you can use binary serialization, but that is dangerous in sense that version of object must be exactly the same - any change in internal fields of the class will cause deserialization failure. Apart from that problem, binary serialization produces much smaller output.
Power of this way of working is that it's simple - serializing and deserializing one object takes only several lines of code, regardless of object complexity.
Drawback of this way of serialization is that you have to write class knowing in advance that it will be serialized. For example, all content must be gettable and settable via properties. Nothing that is set like using AddThis method will not be serialized. Also, circular references cannot be serialized (that would end up in infinitely large XML).