Understanding Object Serialization in .NET
Serialization is the process of storing or converting the various data
elements such as class of the object, public and private fields of the
object, and the assembly of an object into a single element called byte
The two most significant reasons to use .NET Object Serialization are to maintain the state of the object in a storage medium so that later you can create another copy of that object and to pass an object across a network. In a normal situation when you want to send an object from one application domain to another domain you have to send single bit of object data at a time. This takes lot of time for the developers.
.NET Framework has Common Language Runtime (CLR) to manage objects and automates the serialization process by using reflection. When the object is serialized all the data elements of the object are written to a storage medium and the references of the instances of the objects are stored in member variables. The serialization engine keeps track of all the serialized objects so that the object that has been serialized once cannot be serialized again.
The most convenient way to make an object serializable is to mark it with the Serializable attribute. This will also allow the object to be shifted from one application domain to the other and then deserialize it to create an exact copy of the object in another domain. This mechanism is known as marshal by value. The .NET Framework generally provides two types of serialization: shallow serialization and deep serialization. The process of shallow serialization converts only the read-write property values of an object into a byte stream whereas the deep serialization converts the actual values that are stored in the private variables of an object into a byte stream. Shallow serialization is used by XMLSerializer and Web Services whereas deep serialization is used Binaryformatter, Soapformatter, and .NET Remoting.
Some of the
features of serialization/deserialization include:
to our mailing list and receive new articles Note
: We never rent, trade, or sell my email lists to Visit
.NET Programming Tutorial Homepage ______________________________________________________
to our mailing list and receive new articles
: We never rent, trade, or sell my email lists to
Visit .NET Programming Tutorial Homepage