none
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:window

    Question

  • Hi,

       I have a WCF (full duplex) , I try to call the following function:

     

    [WebInvoke(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
    void Server_Window(string SecurityTokenKey, string Name, Int64 ID, Window_DataInfo window);
    

    /////  --->
    [DataContract]
        public class Window_DataInfo
        {
            [DataMember]
            public int LocationX { get; set; }
            [DataMember]
            public int LocationY { get; set; }
            [DataMember]
            public int Width { get; set; }
            [DataMember]
            public int Heigh { get; set; }
            [DataMember]
            public byte[] Image { get; set; }
        }

    I call this from client:

    Program.ServerBridgeProxy.Proxy.Server_WindowPaint("xxx","name", 1, new Window_DataInfo
                    {
                        Heigh = 100,
                        Width = 100,
                        LocationX = 21,
                        LocationY = 23,
                        Image = this.generatedata(new Size(100,100))
                    });
    
    
     byte[] generatedata(Size imgSize)
            {
               System.Random rd = new Random(127);
                byte[] s = new byte[imgSize.Width*imgSize.Height];
                Random random = new Random();
                char ch;
    
                for (int i = 0; i < s.Length; i++)
                {
                    ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));
                    s[i] = Convert.ToByte(ch);
                }
               
                return s;
            }
    

     

    Calling as above:  Image = this.generatedata(new Size(100,100))

    Work great in loop for few minutes with no failed, but when change it to: Image = this.generatedata(new Size(200,100))

    I got the following error:

     

    The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:window. The InnerException message was 'There was an error deserializing the object of type TAKO_BridgeNameSpace.Window_DataInfo. The maximum array length quota (16384) has been exceeded while reading XML data. This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 27303.'.  Please see InnerException for more details.

     


    The problem is (I don't know why!!!!) all my config files include the data binding with length = "2147483646"  - (see below), I also run the replace in all solution and change all numbers to 2147483646, even inside the "configuration.svcinfo", recompile and run with no change!!!!

    I did the same in the service side (Config files)

    Here my client side config file:

     

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <system.serviceModel>
        <bindings>
          <wsDualHttpBinding>
            <binding name="WSDualHttpBinding_I_BridgeWCFService" closeTimeout="00:01:00"
              openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
              bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
              maxBufferPoolSize="2147483646" maxReceivedMessageSize="2147483646"
              messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
              <readerQuotas maxDepth="2147483646" maxStringContentLength="2147483646"
                maxArrayLength="2147483646" maxBytesPerRead="2147483646" maxNameTableCharCount="2147483646" />
              <reliableSession ordered="true" inactivityTimeout="00:10:00" />
              <security mode="Message">
                <message clientCredentialType="Windows" negotiateServiceCredential="true"
                  algorithmSuite="Default" />
              </security>
            </binding>
          </wsDualHttpBinding>
        </bindings>
        <client>
          <endpoint address="http://localhost:4414/_BridgeWcfService.svc"
            binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_I_BridgeWCFService"
            contract="_BridgeWcfServiceReference.I_BridgeWCFService"
            name="WSDualHttpBinding_I_BridgeWCFService">
            <identity>
              <dns value="localhost" />
            </identity>
          </endpoint>
        </client>
      </system.serviceModel>
    </configuration>
    
    


     

    and the service side (web.config):

     

    <?xml version="1.0"?>
    <configuration>
      <system.serviceModel>
        <bindings>
          <wsDualHttpBinding>
            <binding name="WSDualHttpBinding_I_BridgeWCFService" closeTimeout="00:01:00"
              openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
              bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
              maxBufferPoolSize="2147483646" maxReceivedMessageSize="2147483646"
              messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
              <readerQuotas maxDepth="32" maxStringContentLength="2147483646"
                maxArrayLength="2147483646" maxBytesPerRead="2147483646" maxNameTableCharCount="2147483646" />
              <reliableSession ordered="true" inactivityTimeout="00:10:00"/>
              <security mode="Message">
                <message clientCredentialType="Windows" negotiateServiceCredential="true"
                  algorithmSuite="Default" />
              </security>
            </binding>
          </wsDualHttpBinding>
        </bindings>
        <services>
          <service behaviorConfiguration="_BridgeNameSpace.Service1Behavior" name="_BridgeNameSpace._BridgeWCFService">
            <!-- Service Endpoints -->
            <!-- Unless fully qualified, address is relative to base address supplied above -->
            <endpoint address ="" binding="wsDualHttpBinding" contract="_BridgeNameSpace.I_BridgeWCFService">
              <!-- 
                  Upon deployment, the following identity element should be removed or replaced to reflect the 
                  identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
                  automatically.
              -->
              <identity>
                <dns value="localhost"/>
              </identity>
            </endpoint>        
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
          </service>
         </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="_BridgeNameSpace.Service1Behavior">
              <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
              <serviceMetadata httpGetEnabled="true"/>
              <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
              <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
           </serviceBehaviors>
        </behaviors>
    
      </system.serviceModel>
      <system.web>
        <compilation debug="true" targetFramework="4.0"/>
        <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
      </system.web>
    </configuration>
    


     

    WHY?!


     

     

     


    • Edited by Markos_King Thursday, December 08, 2011 11:57 AM
    Thursday, December 08, 2011 11:56 AM

Answers

  • Binding configuration is not defined on the service endpoint...

     

    <endpoint address ="" binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_I_BridgeWCFService" contract="_BridgeNameSpace.I_BridgeWCFService">
    

    Hope it helps


    Can Bilgin
    Blog CompuSight
    • Marked as answer by Markos_King Thursday, December 08, 2011 9:11 PM
    Thursday, December 08, 2011 3:10 PM