Error on returning a byte-array from WCF. There was an error deserializing the object of type System.Byte[] RRS feed

  • Question

  • hi,

    I wrote a WCF Server Application which must build a file and return it to the client as an array of bytes. It works, but when testing the application on several users' computers, I found that error message

    I have to specify that the error occurred on a client computer, while on others the app works correctly. So, I guess issue is due to some computer setting. Any idea of how to resolve it?

    To provide more details, my app is a WPF application built using the MVVM pattern. The WCF service is attached to the ViewModel layer, while the endpoint to the service is put on the View layer. This is the View/app.config snippet code

            <binding name="BasicHttpBinding_IAppService" maxReceivedMessageSize="2147483647" />
          <endpoint address="http://..../AppWebService/AppService.svc" binding="basicHttpBinding"
            bindingConfiguration="BasicHttpBinding_IAppService" contract="AppWebService.IAppService"
            name="BasicHttpBinding_IAppService" />
    the same snippet code is put in ViewModel/app.config
    Tuesday, March 25, 2014 11:17 AM


  • Two options - first is to use streams instead of Byte[] to xfer the file. Downside - bunch of limitations to getting this work around the arguments you pass and additional config requirements.

    Second (and probably what you're after), allow your server to send bigger arrays. It's in the binding section like so:

        <binding maxReceivedMessageSize="20000000">
        <readerQuotas maxArrayLength="20000000"/>
    I included the other max because if you get one, you'll probably also get the other.

    Tuesday, March 25, 2014 9:25 PM