.NET Object Serialization – How can I optimize the serialization process?
How can I optimize the serialization process?
The first call to a Web Service takes long because XmlSerializer generate an assembly optimized for each type in memory.
To optimize the serialization process pregeneration of serialization assembly with Visual Studio or sgen.exe is needed.
Implementing serialization separately can also increase the performance.
What is Formatters? Explain the binary formatter and the SOAP formatter.
A formatter determines the serialization format for objects.
.NET framework provides Binary formatter and SOAP formatter which inherit from the IFormatter interface
The Binary Formatter
It provides binary encoding for compact serialization for storage or socket-based network streams.
It is not appropriate for data to be passed through a firewall.
The SOAP Formatter
It provides formatting that can be used to enable objects to be serialized using the SOAP protocol.
The class is used for serialization through firewalls or diverse systems.
.NET interview: What is the difference between the SoapFormatter and the XmlSerializer
SoapFormatter
SOAP formatter will actually take the field values of an object and store all of that information in the stream passed.
SoapFormatter is better to serialize arbitrary data
XmlSerializer
XML Serialization would just serialize the public properties of an object.
The XML Serializer is used typically for serializing simple types across web services
xmlserializer is better, more flexible and faster