answersLogoWhite

0

SerializationSerialization is a process of taking an object and converting into a form so that it can be transported across the network or can be persisted in the storage location. This storage location can be physical file, database or ASP.NET Cache. The form contains the state of the object so that by this format, we can construct the same object a later point in time, which is called Deserialization.

There are three formats of serialization

Binary Serialization : Light and compact used in Remoting

SOAP Serialization : interoperable use SOAP and used in web Services

XML Serialization : Custom Serialization

XML Serialization

For XML serialization, you need to use the attributes and specify them for each and every public member that you need. But since it is limited that it can serialize only public members, Serization done by it is called custom serialization. It is also known as Shallow Serialization

SOAP and Binary Serialization

XML serializes only public members of the class. You use SOAP or Binary serialization when you need to transport data across the network. SOAP sends it using HTTP Protocol which makes it most interoperable while Binary serialization is known for its light and compact nature. Web Services uses the SOAP Serialization and Remoting uses the Binary Serialization. Infact Serialization is always necessary when you need the object to transfer across a network. Advantage of using the SOAP or Binary serialization is that you can serialize the entire object and all those object that are being refrenced by it. This is why it is also called Deep Serialization. If you want any class to serialize through any of these methods then you should use [Serializable] attribute on that class and then you can use the SoapFormater class or BinaryFormatter class to do the serialization. These classes have Serialize and DeSerialize method. If you will not use SerializableAttribute for the class, then it will raise the exception.

Though this is the easiest way but at time you need the way so that you can decide what fields to serialize and how the serialization actually occurs. You can implement the ISerializable interface in the class. You need two things for that

  1. Constructor that is overridden and can handle the Deserialization process
  2. GetObject method that tracks about which data is serialized.

A small example below illustrate this all.

public class Employee :ISerializable

{

private int emp_no;

private string name;

protected TestData(SerializationInfo info,StreamingContext context)

{

this.emp_no = info.GetInt32("emp_no");

this.name = info.GetString("name");

}

void ISerializable.GetObjectData(SerializationInfo info,

StreamingContext context)

{

info.AddValue("emp_no", this.emp_no);

info.AddValue("name", this.name);

}

}

}

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

When was firearm serialization required?

Gun Control Act of 1968 required all firearms to be serialized


What is meaning Serialize in java?

Primary purpose of java serialization is to write an object into a stream, so that it can be transported through a network and that object can be rebuilt again. When there are two different parties involved, you need a protocol to rebuild the exact same object again. Java serialization API just provides you that. Other ways you can leverage the feature of serialization is, you can use it to perform a deep copy. Why I used 'primary purpose' in the above definition is, sometimes people use java serialization as a replacement for database. Just a placeholder where you can persist an object across sessions. This is not the primary purpose of java serialization. Sometimes, people say that java serialization is used for storing (to preserve the state) an object and retrieving it. They use it synonymously with database. This is a wrong perception for serialization.


What is deserialization in java?

De-serialization is the opposite process of serialization. This is the process where we convert data that has already been written out onto a stream as part of serialization into Java objects.


Is surbrec Nora the second out in Engligh?

No it's currently in serialization


What is two ways to score in soccer?

Kick the ball into the net or hit the ball with your head into the net.


How does pigeon deterrent work?

There are several ways to find a working pigeon deterrent. One can try a bird net, bird spikes, bird control wire, bird shock and a flight diverter. There are many ways that can be used at the Bird Busters website.


What is the process of writing the state of an object to a byte stream called?

This is called serialization.


What is the default serialization used for ASPNet Ajax calls?

JavaScript Object Notation


What are the key concepts in computer science serialization and how do they impact data storage and transfer processes?

Serialization in computer science refers to the process of converting data structures or objects into a format that can be easily stored or transmitted. The key concepts in serialization include encoding data into a specific format, such as JSON or XML, and then decoding it back into its original form. Serialization impacts data storage by allowing complex data structures to be saved in a more efficient manner, and it impacts data transfer by enabling the transmission of data across different systems or platforms.


How can one keep their children from watching videos on Totally NSFW?

There are a few ways that one can keep their children from watching videos on Totally NSFW. This includes using parental control software such as Net Nanny.


How do you use flash videos in asp net?

control in asp.net


What is use of serialization in java?

Serialization will turn a Java Object into a text string (representing it's contents) which can be persisted to a storage device or sent over a network. There is an opposite process of turning the text string representation back into an instanciated Object.