C# 更改创建 XML 阅读器时使用的 XmlDictionaryReaderQuotas 对象的 MaxArrayLength 属性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1035600/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader
提问by OscarRyz
I'm getting the following exception while sending ( or receiving ) a byte array to a C# service.
向 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
For what I can understand the XmlDictionaryreader is created automatically by the webservice.
据我所知,XmlDictionaryreader 是由网络服务自动创建的。
So, how can I change the "MaxArrayLength" property?
那么,如何更改“MaxArrayLength”属性?
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.
上传小于 16kb 的文件。
Files > 16kb are not.
大于 16kb 的文件不是。
Files > 10mb are downloaded without problem.
下载大于 10mb 的文件没有问题。
Where is that property configured?
该属性在哪里配置?
采纳答案by Colin
Is it a WCF service? If so, you can change the maxarraylength in the binding as seen on this SO post:
它是 WCF 服务吗?如果是这样,您可以更改绑定中的 maxarraylength,如this SO post所示:
P.S.Why would you use a custom Service when there are OOTB Sharepoint services that can upload files? i.e. the Lists.asmx like in this article:
PS当有可以上传文件的 OOTB Sharepoint 服务时,为什么要使用自定义服务?即本文中的 Lists.asmx :
回答by BigBoss
Add a <readerQuotas>
element inside the <binding>
element and add MaxArrayLength
property
在<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>