更改创建XML阅读器时使用的XmlDictionaryReaderQuotas对象上的MaxArrayLength属性
-
10-07-2019 - |
题
在向C#服务发送(或接收)字节数组时,我遇到以下异常。
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自动创建的。
那么,我怎样才能更改<!> quot; 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;
}
}
档案<!> lt;上传了16kb。
档案<!> gt; 16kb不是。
档案<!> gt;下载10mb没有问题。
该属性配置在哪里?
其他提示
在<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>
不隶属于 StackOverflow