.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Serialization and deserialization over network is very slow

Posted By:      Posted Date: September 23, 2010    Points: 0   Category :.NET Framework

I am using the built in C# serialization and deserialization functionality to pass objects over network streams and it works fine. The problem iswhen the client and server programs are running on different computers, sending even the simplest objects over the pipe using serialization is painfully slow (about 50x slower than using byte arrays). If I have the client running on the same box as the server, the serialization approach is nearly as fast as the byte array approach (even though network sockets and serialization are still used). It only slows down when the client and server are running on different machines. Clearly, Serialization is not the cause of the slow down. So why is it so much slower than the byte array approach when the server and client are not on the same computer? Thanks for any help. 


I have put together a simple client/server program to demonstrate this oddity:

namespace PingTest {
 class Server {
  public static void Start() {
   System.Runtime.Serialization.Formatters.Binary.BinaryFormatter binFormatter =
     new System.Runtime.Serialization.Formatters.Binary.Binar

View Complete Post

More Related Resource Links

Why does .NET Framework 4 client profile slow down boot time network creation?

I've been running a Windows XP sp3 KVM virtual machine for a long time now, and some recent update made the initial network startup go from a few seconds at boot time to around 90 seconds. Using Add/Remove program to uninstall recent updates points the finger at .NET Framework 4 client profile. With it installed, if I right click on network and ask for properties right after booting, there is a 90 second delay before the network dialog with the list of network interfaces finally appears. In addition, the network drive I have automounted at login is not accessible for the same 90 seconds. As an experiment, I tried going into the device manager and deleting the network interface, and if I reboot after that it takes 90 seconds for the new hardware wizard to appear. All these 90 second delays vanish if I remove this .NET update. The network comes up as soon as the system boots.

Using Serialization/Deserialization versus flat file for Interprocess Communication?


I have a process A that gathers data and hands it over for processing to process B. The amount of data is anywhere near 650MB or more, the transport should be as fast as possible, yet painless (if possible). A and B are different processes, so the scenario could be considered Inter Process Communication.

Here is what I've done and found so far:

  1. Process A created an object filled with all information and serialized it into a file. B deserialized and processed the data.
    - the computational time on the serialization is OK.
    - the deserialization is many times bigger than serialization to the point that I consider it useless because it takes too long.
  2. I do not serialize/deserialize instead use a flat file for the communication.
    - it's quick and same speed for read and write
    - lacks flexibility and is not very elegant either.
  3. I used namedPipes to transfer the serialized object between processes A and B, which is elegant but ever slower because of the issue in #1 and the fairly poor performance of namedPipes and big data?



  1. Can somebody please advise me on how to best deal with my requirements?
  2. Explain to me why deserialization is soooo slow (I understand that depending on type a lot of object have to be created) and what better approach one should take.

serialization over network gives decoderfallbackexception


So, I have two instances of a software communicating over a network by serializing and deserializing objects.  Unfortunately, every now and then, on deserialization, I get a decoderfallbackexception and I have no idea why or how to fix it.

Here's a simplified version of the client.  The server is very similar.

public class Client
  TcpClient tcpClient;
  NetworkStream netStream;
  BinaryFormatter formatter;
  Thread thread;

  public Client(string host, int port)
    tcpClient = new TcpClient(host, port);
    netStream = tcpClient.GetStream();
    formatter = new BinaryFormatter();
    thread = new Thread(Run);

  public void Send(Message msg)
      formatter.Serialize(netStream, msg);

Response.Redirect slow


I'm in the middle of migrating servers and on the new server Response.Redirect is extremely slow. It takes around 20 seconds for the browser to get the redirect. This is something that was quick on the existing server. It's an ASP.NET 2.0 application, both servers are running IIS6.

Additionally, if I "manually" do the redirect, it's fast. For example:

Existing way:


takes around 20 seconds on the new server

New way:

Response.Status = "302 Moved Temporarily";
Response.AddHeader("Location", url);

is fast on the new server.

Any ideas why Response.Redirect would be so slow on the new server?

VS 2010 Pro is slow



I was wondering if anybody else is finding VS 2010 extremely slow loading a solution - and it pretty much renders the rest of the machine useless until loaded. Everything is slowed to a halt.

I upgraded from VS 2005 - now I think I made a terrible mistake. I cannot afford to try and load 2 solutions simultaneously.

The machine is a Core2 Duo E8400, 3GB of RAM, WinXP SP3. Max I can go to is 4GB. Would upgrading to a 64-bit OS really be worth it (actually only to get 8GB of RAM)?

I'm hoping someone else has found a solution to this particular problem.



Using network login



Is anyone have sample code to set up log in page using network login?

For example: User Name(same as Network Login)

                     Password(Same as Network Login)

Your help is highly appreciated.

Json Deserialization is giving error in IronPython



Have anyone tried json deserialization. When I tried:

>>> import json

>>> json.loads('["foo", {"bar":["baz", '"Test", 1.0, 2]}]')

I got following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\IronPython 2.6 for .NET 4.0\Lib\json\__init__.py", line
 307, in loads
  File "C:\Program Files\IronPython 2.6 for .NET 4.0\Lib\json\scanner.py", line
42, in iterscan

WCF P2P: How To Design State Sharing in a Peer Network


Learn how you can peer-enable business applications by allowing them to share state in a serverless peer network.

Kevin Hoffman

MSDN Magazine July 2008

.NET Matters: Deserialization Progress, and More


Build a standard progress bar that indicates how much deserialization has completed and how much still remains. Plus, System.Collection.Generics performance.

Stephen Toub

MSDN Magazine December 2006

Service Station: Serialization in Windows Communication Foundation


Windows Communication Foundation supports several serialization mechanisms and provides a simple, interoperable foundation for future service-oriented applications. Here Aaron Skonnard explains it all.

Aaron Skonnard

MSDN Magazine August 2006

Class To Contract: Enrich Your XML Serialization With Schema Providers In The .NET Framework


The Microsoft .NET Framework 1.x provided minimal options for mapping classes to schemas and serializing objects to XML documents, making this sort of mapping quite a challenge. The .NET Framework 2.0 changes all this with Schema providers and the IXmlSerializable interface.

Keith Pijanowski

MSDN Magazine June 2006

Wandering Code: Write Mobile Agents In .NET To Roam And Interact On Your Network


In artificial intelligence, an agent is a logical entity that has some level of autonomy within its environment or host. A mobile agent has the added capability that it can move between hosts. In this article Matt Neely brings mobile agents from the halls of academia to a dev shop near you.

Matt Neely

MSDN Magazine February 2006

Advanced Serialization: Format Your Way to Success with the .NET Framework Versions 1.1 and 2.0


While .NET offers adequate support for the simple serialization cases, issues arise when you're attempting to support delegates and subscribers, versioning, and class hierarchies. . In addition, the introduction of generics in The .NET Framework breaks new ground in the complexity of the serialization task and the power of serialization tools. This article discusses these issues and related pitfalls, suggests techniques and workarounds that address them, and recommends when and how to best use the new serialization abilities.

Juval Lowy

MSDN Magazine October 2004

Cutting Edge: Binary Serialization of DataSets


The ADO. NET DataSet object plays an essential role in most of today's distributed, multitiered applications. Instances of the DataSet class are used to move data across the tiers and to exchange data with external services.

Dino Esposito

MSDN Magazine October 2004

Cutting Edge: Binary Serialization of ADO.NET Objects


One of the key elements that makes ADO. NET superior to ADO is the level of integration with XML. In ADO, XML is just an I/O format. In addition, the ADO XML format is totally inflexible and doesn't allow any type of customization.

Dino Esposito

MSDN Magazine December 2002

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend