读取XML数据时,已超过最大数组长度配额(16384)。

7

我遇到了以下错误:

在读取 XML 数据时,已超出最大数组长度限制(16384)。可以通过更改创建 XML 读取器时使用的 XmlDictionaryReaderQuotas 对象上的 MaxArrayLength 属性来增加此限制。第 1 行,第 187231 个位置。 描述:当前 Web 请求的执行期间发生未经处理的异常。请检查堆栈跟踪以获取有关错误的更多信息以及其在代码中的起源。

异常详细信息:

System.Xml.XmlException: 在读取 XML 数据时,已超出最大数组长度限制(16384)。可以通过更改创建 XML 读取器时使用的 XmlDictionaryReaderQuotas 对象上的 MaxArrayLength 属性来增加此限制。第 1 行,第 187231 个位置。

错误来源:

在执行当前 Web 请求时生成了一个未经处理的异常。可以使用下面的异常堆栈跟踪来确定异常的来源和位置。

堆栈跟踪:

[XmlException: 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 1, position 187231.]
   System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3) +311
   System.Xml.XmlExceptionHelper.ThrowMaxArrayLengthExceeded(XmlDictionaryReader reader, Int32 maxArrayLength) +59
   System.Xml.XmlBaseReader.ReadContentAsBase64() +1580759
   System.Xml.XmlDictionaryReader.ReadElementContentAsBase64() +62
   System.Runtime.Serialization.XmlReaderDelegator.ReadElementContentAsBase64() +58
   ReadPDFResponseFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] ) +525
   System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context) +47
   System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader) +15
   System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, DataContract& dataContract) +128
   System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns) +39
   System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName) +167
   System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName) +98

[SerializationException: There was an error deserializing the object of type Compass.GK.DataCommon.PDFResponse. 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 1, position 187231.]
   System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName) +496
   System.Runtime.Serialization.DataContractSerializer.ReadObject(XmlDictionaryReader reader, Boolean verifyObjectName) +44
   System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest) +52

[NetDispatcherFaultException: The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:PDFRequestResult. The InnerException message was 'There was an error deserializing the object of type Compass.GK.DataCommon.PDFResponse. 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 1, position 187231.'.  Please see InnerException for more details.]
   System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +7599119
   System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +275
   Compass.GK.Datalink.WebServiceReference.ICompassGKService.PDFRequest(Request request) +0
   Compass.GK.Datalink.RequestMaker.PDFRequest(String encryptionKey, String PDFType, String userName) +164
   GKService.GKPDFHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext context) in C:\Joxin\GreenekingApplication\Application\GKService\GKPDFHandler.cs:66
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

my web.cofing client side entry is like this
        <binding name="BasicHttpBinding_ICompassGKService" closeTimeout="00:01:00"
         openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
         allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
         maxBufferSize="2097152" maxBufferPoolSize="524288" maxReceivedMessageSize="2097152"
         messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
         useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="2097152"
            maxBytesPerRead="4096" maxNameTableCharCount="2097152" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>

我不知道有什么遗漏?但是当我在本地访问vs.net 2008时,它可以正常工作。

但是当我将我的应用程序发布到服务器上时,这个问题就出现了。

谢谢

shaji


当发生这种情况时,您当时在尝试做什么? - Marcelo Cantos
3个回答

10

0

0
在配置文件的绑定部分上面添加此部分。这就是答案!将其替换为您自己的参数值。服务器和客户端的配置文件应该匹配!
<services>
    <service name="ReportService.Service1">
        <endpoint address="http:/<Your Web Address>/reportservice/service1.svc"
            binding="basicHttpBinding"
            bindingConfiguration="BasicHttpBinding_IService1"
            contract="ReportService.IService1" />
    </service>
</services>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接