Is it possible to customize Serializer? RRS feed

  • Question

  • Hi Everyone,


    I was trying to implement a simple application to send some data from one PC to another, as a practice of WCF. And I found when the data is of small size (say, some text), the transform speed is fine. However when I am trying to send some larger data (e.g, a very large bitmap), I get TimeOut exception back.


    I also saw some complains about XML Reader Quota, and I solve the problem by:

    Code Snippet
    NetTcpBinding duplexBinding = new NetTcpBinding(SecurityMode.None, true);
    duplexBinding.SendTimeout = new TimeSpan(0, 0, 10);
    XmlDictionaryReaderQuotas quotas = new XmlDictionaryReaderQuotas();
    quotas.MaxStringContentLength = 6553500;
    duplexBinding.ReaderQuotas = quotas;
    duplexBinding.MaxReceivedMessageSize = 6553500;


    Also, as shown above, I am using NetTcpBinding. The network speed is trivial, the server and client are actually on the same machine.
    I saw DataContractSerializer is derived from XmlObjectSerializer, does DataContractSerializer serialize my data as XML and then transfer it through network? If this is the case, I am thinking if there has anyway that I can specify my own Serializer, which is using binary format so the size would be smaller than XML?
    As there are mostly binary data (byte[]) in my class that need to be transferred,  I think this might be able to help improve the performance. Does anyone have any clue about how to improve this?
    Thanks in advance!
    Wednesday, April 9, 2008 4:29 PM


All replies