Changing the MaxArrayLength property of the XmlDictionaryReaderQuotas object used to create the XML reader

I get the following exception when sending (or receiving) a byte array to a C # service.

There was an error deserializing the object of type System.Byte[]. 
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 6, position 34838.'.  
Please see InnerException for more details

For what I can understand, XmlDictionaryreader is automatically created by the web service.

So how can I change the MaxArrayLength property?

This is the implementation code:

    public string addFile(string sharePointServer, string documentLibrary, 
                          byte[] content, string fileName) 
    {
        try
        {
            SPWeb spWeb = new SPSite(sharePointServer).OpenWeb();
            SPFolder spFolder = spWeb.GetFolder(documentLibrary);
            SPFileCollection spFileCollection = spFolder.Files;
            SPFile spFile = spFileCollection.Add(fileName, content, true);
            return spFile.TimeCreated.ToLongDateString() + "::" + spFile.Title;
        } 
            catch (Exception ex) 
        {
            throw ex;
        }
    }

Files <16kb are uploaded.

Files> 16kb - no.

Files> 10mb load without problems.

Where is this property configured?

+3
source share
2 answers

Is this a WCF service? If so, you can change the maxarraylength in the binding, as shown in this SO post:

message

P.S.. , OOTB Sharepoint, ? List.asmx, :

+7

<readerQuotas> <binding> MaxArrayLength

 <bindings>
     <wsHttpBinding>
         <binding name ="Your WSHttpBinding Name" sendTimeout="00:05:00" maxReceivedMessageSize="2147483647">
             <security mode="None"></security>
             <readerQuotas maxStringContentLength="134217728" maxArrayLength="2147483647" />
             <reliableSession enabled="true"/>
         </binding>
     </wsHttpBinding>
 </bindings>
+1

Source: https://habr.com/ru/post/1711135/


All Articles