【问题标题】:WCF with netTcpBinding binding and maxReceivedMessageSize error messageWCF 与 netTcpBinding 绑定和 maxReceivedMessageSize 错误消息
【发布时间】:2014-02-10 09:00:01
【问题描述】:

我正在尝试正确设置我的 App.Config 以允许我的 NetTcp 服务返回大于 65536 的字符串,因为我在下面收到此错误

传入邮件的最大邮件大小配额 (65536) 已达到 超过。要增加配额,请使用 MaxReceivedMessageSize 相应绑定元素上的属性。

到目前为止,这是我尝试过的,但它不起作用,我希望有人能指出我的错误

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <system.web>
    <compilation debug="true" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="NetTcpSHWS.Service1" behaviorConfiguration="NetTcpSHWS.Service1Behavior">
        <host>
          <baseAddresses>
            <add baseAddress = "net.tcp://localhost:8732/Design_Time_Addresses/NetTcpSHWS/Service1/" />
          </baseAddresses>
        </host>
        <endpoint name="NetRcpEndPoint" address ="" binding="netTcpBinding" bindingConfiguration="netMyConfig" contract="NetTcpSHWS.IService1">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint name="NetTcpMetadataPoint" address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="NetTcpSHWS.Service1Behavior">
          <serviceMetadata httpGetEnabled="false"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
          <dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483646" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <netTcpBinding>
        <binding name="netMyConfig"
                 maxBufferSize="2147483647"
                 maxBufferPoolSize="2147483647"
                 maxReceivedMessageSize="2147483647"
                 transferMode="Buffered">
          <readerQuotas maxDepth="32"
                        maxStringContentLength="2147483647"
                        maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647" />
        </binding>
      </netTcpBinding>
    </bindings>
  </system.serviceModel>
</configuration>

这只是一个测试应用

【问题讨论】:

标签: c# wcf nettcpbinding


【解决方案1】:

添加bindingConfiguration:

<endpoint name="NetRcpEndPoint" bindingConfiguration="myConfiguration" ... >

<netTcpBinding>
    <binding name="myConfiguration" ...
    </binding>
</netTcpBinding>

如果不这样做,将不会使用您的绑定配置(将使用默认配置)。

【讨论】:

  • 您好,感谢您的回答,我进行了更改,但仍然出现错误,我更新了原始帖子中的配置设置
猜你喜欢
  • 1970-01-01
  • 2011-11-13
  • 1970-01-01
  • 2013-09-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-22
  • 2010-10-08
相关资源
最近更新 更多