【问题标题】:c# WCF maximum string content length quotac# WCF最大字符串内容长度配额
【发布时间】:2017-02-17 16:21:31
【问题描述】:

我知道这已经发布了几次,但我开始拔头发了...我收到以下错误:

格式化程序在尝试反序列化消息时抛出异常:反序列化操作“CreateEmailEntry”的请求消息正文时出错。读取 XML 数据时已超出最大字符串内容长度配额 (8192)。可以通过更改创建 XML 阅读器时使用的 XmlDictionaryReaderQuotas 对象的 MaxStringContentLength 属性来增加此配额。第 157 行,第 92 位。

这里是端点配置:

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IAddEmail" maxReceivedMessageSize="65536">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
            maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost/AutoSearchEmail/AddEmail.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAddEmail"
        contract="ServiceReference1.IAddEmail" name="BasicHttpBinding_IAddEmail" />
    </client>
  </system.serviceModel>

这是 WCF 项目的配置:

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IAddEmail" maxReceivedMessageSize="65536">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
            maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

我已经阅读了很多帖子,上面写着“增加 maxStringContentLength”,我相信我有,但它很可能是我忽略的...

我真的不喜欢在代码中创建端点的想法 - 听起来像是额外的一层会出错!

提前致谢。

【问题讨论】:

  • 你试过 maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
  • 刚刚添加了相同的结果:(

标签: c# wcf


【解决方案1】:

对于服务配置,这是你的全部配置吗,因为我错过了

 <services>

将绑定应用到服务的部分。

【讨论】:

  • Bang on - 我确实使用 WCF 服务配置编辑器让我的生活更轻松。谢谢!
猜你喜欢
  • 2011-11-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多