更改创建 XML 阅读器时使用的 XmlDictionaryReaderQuotas 对象的 MaxArrayLength 属性 [英] Changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader

查看:16
本文介绍了更改创建 XML 阅读器时使用的 XmlDictionaryReaderQuotas 对象的 MaxArrayLength 属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在向 C# 服务发送(或接收)字节数组时遇到以下异常.

I'm getting the following exception while 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

据我所知,XmlDictionaryreader 是由网络服务自动创建的.

For what I can understand the XmlDictionaryreader is created automatically by the webservice.

那么,如何更改MaxArrayLength"属性?

So, how can I change the "MaxArrayLength" property?

这是实现代码:

    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.

Files < 16kb are uploaded.

大于 16kb 的文件不是.

Files > 16kb are not.

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

Files > 10mb are downloaded without problem.

该属性在哪里配置?

推荐答案

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

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

帖子

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

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:

文章

这篇关于更改创建 XML 阅读器时使用的 XmlDictionaryReaderQuotas 对象的 MaxArrayLength 属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆