Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What data is passed in Serialization? (Binary Serialization)

In serialization (Binary Serialization) what data is being transferred? An instance of a class (object) or values assigned to that object's properties.

I want to know what happens in the serialization process basically? I mean an object is converted to it's target file or whatever in serialization. But how? What steps are followed in this process?

Can someone help?

Jay...

like image 433
Jaywith.7 Avatar asked May 30 '09 09:05

Jaywith.7


People also ask

What data types are serializable?

The following types built into the . NET Framework can all be serialized and are considered to be primitive types: Byte, SByte, Int16, Int32, Int64, UInt16, UInt32, UInt64, Single, Double, Boolean, Char, Decimal, Object, and String.

What is binary serialization?

Serialization is the process of storing the state of an object to a storage medium. In binary serialization, the public and private fields of the object and the name of the class, including the assembly containing the class, are converted to a stream of bytes, which is then written to a data stream.

Which data is serialization?

Data serialization is the process of converting an object into a stream of bytes to more easily save or transmit it. The reverse process—constructing a data structure or object from a series of bytes—is deserialization.

Is a binary serialization format?

Serialization is the process of translating data structures or object state into a format that can be stored and resurrected later in the same or another computer environment.


1 Answers

Binary Serialization is taking snap shoot of object and serializes it. Meaning all private fields, that are not marked as NonSerializable, will be serialized with their values. All objects used in object hierarchy must be maked as Serializable. You should put [field:NonSerializable] attribute on events, so event handlers don't get serialized too: http://bytes.com/groups/net-c/250944-nonserialized-attribute-events#post1013968

Keep in mind that when deserializing object, you have to have exactly the same object in same assembly as when you serialized it (same meaning same assembly info). If not, you can use SerializationBinder class so you can reset type in which stream will be sterilized.

like image 72
Andrija Avatar answered Sep 22 '22 11:09

Andrija