تغيير MaxArrayLength الملكية على إكسملديكتيوناريريديرقوتاس المستخدم عند إنشاء XML القارئ

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 في ملزمة كما نشاهد في هذا المنصب:

بعد

P. S. لماذا استخدام خدمة مخصصة عندما يكون هناك OOTB Sharepoint services التي يمكنك تحميل الملفات ؟ أيقوائم.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