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

发布于 2025-01-11 08:47:19 字数 3360 浏览 0 评论 0原文

我有一个 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”,但这没有帮助。

service 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 文件。我在这里看到了很多关于这个问题的主题,但我找不到任何可以帮助我的东西。唯一的希望就是当地的主宰

i have a wpf app and want to send byte[] to my wcf(plus wpf) using NetTcpBinding but have

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

I saw "MaxBufferSize" and "maxReceivedMessageSize" in the document, but it doesn't help.

service app.config

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

and my client, the full configuration generated automatically from service ref, except binding attribute

<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>

i also try get logs(on client side)

 <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>

but it just doesn't work! it doesn't even generate a .svclog file. i've seen a lot of topics here about this problem, but I couldn't find anything that could help me. the only hope is for the local overmind

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧人 2025-01-18 08:47:19

在服务端的 中,您应该将 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>

in <endpoint> on service side you should add bindingConfiguration="myBind" to you binding like

<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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文