XMLリーダーの作成時に使用されるXmlDictionaryReaderQuotasオブジェクトのMaxArrayLengthプロパティを変更する
-
10-07-2019 - |
質問
バイト配列を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はWebサービスによって自動的に作成されます。
では、<!> quot; MaxArrayLength <!> quot;を変更するにはどうすればよいですか?プロパティ?
これは実装コードです:
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;
}
}
ファイル<!> lt; 16kbがアップロードされます。
ファイル<!> gt; 16kbはそうではありません。
ファイル<!> gt; 10MBは問題なくダウンロードされます。
そのプロパティはどこで設定されていますか?
他のヒント
<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>
所属していません StackOverflow