XML 리더를 생성 할 때 사용되는 xmlDictionaryReaderQuotas 객체에서 MaxArrayLength 속성 변경

StackOverflow https://stackoverflow.com/questions/1035600

문제

바이트 배열을 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 서비스입니까? 그렇다면이 게시물에 표시된대로 바인딩의 MaxArraylength를 변경할 수 있습니다.

게시하다

추신 파일을 업로드 할 수있는 OOTB SharePoint 서비스가있을 때 사용자 정의 서비스를 사용하는 이유는 무엇입니까? 즉,이 기사에서와 마찬가지로 lists.asmx :

기사

다른 팁

을 추가하다 <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>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top