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

查看:177
本文介绍了更改在创建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是由Web服务自动创建的.

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:

发布

PS .当有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天全站免登陆