Basics of Serialization in .NET Framework 3.0
page 2 of 6
by Uday Denduluri
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 28122/ 122

Different Types of encoding

A .NET object can be serialized with different types of encodings. Let us discuss some of the serializations in detail.

·         Binary Serialization – The encoding used for this type of serialization is binary encoding. Using this serialization when an object is serialized, all the public and private fields are serialized. This means that the exact binary copy of the object is replicated. This brings about the concept of cloning an object (using binary serialization we can clone an object). One of the major advantages of Binary Serialization is the performance. The serialization and de-serialization cost would be minimal. However, binary serialization is not easily portable especially with cross platforms.

·         XML Serialization – XML Serialization serializes only the public properties and does not bother the private variables. It is to be noted that the type fidelity is also not preserved. When using XML serialization we cannot guarantee the original state of the objects. The primary purpose of the XML serialization would be conversion of XML documents into .NET objects and .NET objects into XML documents. In spite of having many issues with XML serialization, the main reason it is used is because of its support over cross platforms. In .NET 2.0, the XmlSerializer class takes care of the serialization. It has 2 methods, Serialize and DeSerialize, for serializing and de-serializing.

·         SOAP Serialization – SOAP serialization is a special form of XML serialization, but conforms to the SOAP specification. SOAP is a protocol based on XML designed for transporting method calls over the web. The .NET Framework supports the serialization that conforms to the SOAP standards. We can use the XmlSerializer class that can serialize classes in SOAP standards. SOAP is an example of custom serialization. We will see more about basic and custom serialization in the next sections.

·         Designer Serialization – Designer serialization is a special form of serialization which involves object persistence usually associated with development tools. Designer serialization is generally used in cases of displaying graphs, designer tools, etc. The designer shown in Visual studio is a type pf designer serialization. The emphasis on the designer serialization will be on the object's exact state with respect to other objects visually. It will always help if the designer serialization format is in a human readable format.


View Entire Article

User Comments

Title: Incorrect information   
Name: Bob
Date: 2008-04-22 6:00:25 PM
Comment:
this article states that :
----------------------------
NonSerializedAttribute – If a class is marked as Serializable then all the properties can be serialized. For example, if we have a User object that has properties like user name, password [not in encrypted format], role of the user, etc. then such kinds of crucial information can be leaked out if serialized. We have the NonSerializable attribute that helps us in marking a property as not serializable.
--------------------------------
however, this is totally incorrect. You cannot use the NonSerializable attribute on a Property. It is for fields only, and will generate a compiler error.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-10-09 3:25:25 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search