简体   繁体   English

通过WCF从SQL数据库读取字节数组-maxArrayLength问题

[英]Reading byte array from a SQL database through WCF - maxArrayLength issue

I have a WCF service which is supposed to return a List to my client application. 我有一个WCF服务,应该将List返回到我的客户端应用程序。 One of the columns in the database are byte[] . 数据库中的列之一是byte[] When I try to return this list of Object, I only get a NetDispatcherFaultException with this inner-exception: 当我尝试返回此Object列表时,仅收到带有此内部异常的NetDispatcherFaultException

"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 38697." “读取XML数据时已超出最大数组长度配额(16384)。可以通过更改创建XML读取器时使用的XmlDictionaryReaderQuotas对象上的MaxArrayLength属性来增加此配额。第1行,位置38697。”

I have googled after this and found a that I should increase the maxArrayLength in the web.config , so I did: 我在此之后进行了maxArrayLength搜索,发现我应该在web.config增加maxArrayLength ,所以我做到了:

<protocolMapping>
    <add binding="basicHttpsBinding" scheme="https"/>
    <add binding="basicHttpBinding" scheme="http" 
         bindingConfiguration="CrudserviceBinding" />
</protocolMapping>

<bindings>
    <basicHttpBinding>
        <binding name="CrudserviceBinding" maxReceivedMessageSize="52428800" >
            <readerQuotas maxStringContentLength="10242880"  
                          maxArrayLength="10242880" />
        </binding>
    </basicHttpBinding>
</bindings>

This is my app.config on the client side: 这是我在客户端的app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
              <binding name="BasicHttpBinding_ICrudService">
                <readerQuotas maxStringContentLength="5242880" 
                              maxArrayLength="52428800" />
              </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost/My.Project/CrudService.svc"
                      binding="basicHttpBinding" 
                      bindingConfiguration="BasicHttpBinding_ICrudService"
                      contract="MobileCrudService.ICrudService" 
                      name="BasicHttpBinding_ICrudService" />
        </client>
    </system.serviceModel>
</configuration>

When I try this once more, the WCF service returns the same exception. 当我再次尝试此操作时,WCF服务将返回相同的异常。 Can anybody explain how I should deal with this? 谁能解释我该如何处理?

If you are calling the service in a class Library on the Client, make sure you are changing the actual Application .config file. 如果要在客户端的类库中调用服务,请确保您正在更改实际的Application .config文件。 Do not use 不使用

Products/ProductName/Main/Source/Project_Name/bin/Debug/ProjectName.dll.config

instead use 代替使用

Products/ProductName/Main/Source/Project_EXE_Name/bin/Debug/YourExe.config

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM