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

标签 c# web-services sharepoint arrays

我在向 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 是由网络服务自动创建的。

那么,我该如何更改“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 服务吗?如果是这样,您可以更改绑定(bind)中的 maxarraylength,如此 SO 帖子所示:

post

P.S. 既然有可以上传文件的 OOTB Sharepoint 服务,为什么还要使用自定义服务?即本文中的 Lists.asmx:

article

关于c# - 更改创建 XML 阅读器时使用的 XmlDictionaryReaderQuotas 对象的 MaxArrayLength 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1035600/

相关文章:

java - axis2 服务器和 Android 应用程序之间传递的复杂类型

azure - 使用 Sharepoint API 访问 Sharepoint 自定义 View

c# - 在 C# 中使用枚举

c# - X文档,X元素 : Sequence contains no matching element

c# - 在 TextBox 中查找插入符号的位置

web-services - RestTemplate 返回类型

c# - NHibernate session ObjectDisposedException

wcf - 监控 WCF Web 服务

sharepoint - Microsoft.Sharepoint.dll 的位置在哪里

elasticsearch - 将SharePoint在线索引插入Elasticsearch