Understanding Object Serialization in .NET

.NET Object 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 stream.


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:

• Storing user preferences in an object

• Maintaining security information across pages and applications

• Modification of XML documents without using the DOM

• Passing an object from one application to another

• Passing an object from one domain to another

• Passing an object through a firewall as an XML string

_______________________________________________________________________

Add to My Yahoo!


FREE Subscription

Subscribe to our mailing list and receive new articles
through email. Keep yourself updated with latest
developments in the industry.

Name:
Email:

Note : We never rent, trade, or sell my email lists to
anyone. We assure that your privacy is respected
and protected.

Visit .NET Programming Tutorial Homepage

______________________________________________________

Recommended Resource


| Privacy Policy for www.dotnet-guide.com | Disclosure | Contact |

Copyright - © 2004 - 2017 - All Rights Reserved.