增加 wcf-wpf 服务中的消息大小?

increase message size in wcf-wpf service?

我有一个 wpf 应用程序,想使用 NetTcpBindingbyte[] 发送到我的 wcf(加上 wpf)但是有

QuotaExceededException: The maximum message size quota for the remote channel has been exceeded. For more information, see the server logs

我在文档中看到了“MaxBufferSize”和“maxReceivedMessageSize”,但没有帮助。

服务app.config

<bindings>
    <netTcpBinding>
      <binding name="NetTcpBinding_IService"
               maxBufferSize="20971520"
               maxBufferPoolSize="20971520"
               maxReceivedMessageSize="20971520"
             >
        <readerQuotas maxDepth="32" 
             maxArrayLength="20971520"/>
      </binding>
    </netTcpBinding>
  </bindings>

和我的客户端,从服务引用自动生成的完整配置,绑定属性除外

<bindings>
  <netTcpBinding>
      <binding name="NetTcpBinding_IService"
               maxBufferSize="20971520"
               maxBufferPoolSize="20971520"
               maxReceivedMessageSize="20971520"
             >
        <readerQuotas maxDepth="32" 
             maxArrayLength="20971520"/>
      <security>
        <transport sslProtocols="None" />
      </security>
    </binding>
  </netTcpBinding>
</bindings>

我也尝试获取日志(在客户端)

 <system.diagnostics>
    <sources>
        <source name="System.ServiceModel.MessageLogging" switchValue="Warning,ActivityTracing">
            <listeners>
                <add type="System.Diagnostics.DefaultTraceListener" name="Default">
                    <filter type="" />
                </add>
                <add name="ServiceModelMessageLoggingListener">
                    <filter type="" />
                </add>
            </listeners>
        </source>
        <source propagateActivity="true" name="System.ServiceModel" switchValue="Warning,ActivityTracing">
            <listeners>
                <add type="System.Diagnostics.DefaultTraceListener" name="Default">
                    <filter type="" />
                </add>
                <add name="ServiceModelTraceListener">
                    <filter type="" />
                </add>
            </listeners>
        </source>
    </sources>
    <sharedListeners>
        <add initializeData="L:\Projects\Service\Client\Client\App_messages.svclog"
            type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
            <filter type="" />
        </add>
        <add initializeData="L:\Projects\Service\Client\Client\App_tracelog.svclog"
            type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
            <filter type="" />
        </add>
    </sharedListeners>
    <trace autoflush="true" />
</system.diagnostics>

但这根本行不通!它甚至不生成 .svclog 文件。我在这里看到了很多关于这个问题的话题,但我找不到任何可以帮助我的东西。唯一的希望是当地的统治者

in <endpoint> 在服务端你应该添加 bindingConfiguration="myBind" 到你的绑定像

<binding name="NetTcpBinding_IService" 
             transferMode="Buffered"
             maxBufferPoolSize="20971520" 
             maxBufferSize="20971520" 
             maxReceivedMessageSize="20971520"/>
<services>
      <service name="name">
        <endpoint bindingConfiguration="NetTcpBinding_IService" 
              address="you address" 
              binding="netTcpBinding" contract="you contract"/>
      </service>
</services>