更改创建XML阅读器时使用的XmlDictionaryReaderQuotas对象上的MaxArrayLength属性

在向C#服务发送(或接收)字节数组时,我遇到以下exception。

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 

据我所知,XmlDictionaryreader是由webservice自动创建的。

那么,我该如何更改“MaxArrayLength”属性?

这是实现代码:

  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; } } 

文件<16kb已上传。

文件> 16kb不是。

文件> 10mb下载没有问题。

该属性配置在哪里?

它是WCF服务吗? 如果是这样,您可以更改绑定中的maxarraylength,如此SOpost所示:

岗位

PS当有OOTB Sharepoint服务可以上传文件时,为什么要使用自定义服务? 即本文中的Lists.asmx:

文章

元素中添加元素并添加MaxArrayLength属性