简体   繁体   English

WCF服务-MaxReceivedMessageSize错误

[英]WCF Service - MaxReceivedMessageSize Error

I have my WCF Service hosted in Windows Service. 我在Windows Service中托管了WCF服务。 The client application is a website project to which I add Service reference. 客户端应用程序是一个网站项目,我向其中添加了Service参考。

Now, Windows Service configuration file has the right settings for MaxReceivedMessageSize: 现在,Windows Service配置文件具有MaxReceivedMessageSize的正确设置:

  <netTcpBinding>
    <binding name="netTcp" maxBufferPoolSize="50000000" maxReceivedMessageSize="50000000">
      <readerQuotas maxDepth="500" maxStringContentLength="50000000" maxArrayLength="50000000"
                    maxBytesPerRead="50000000" maxNameTableCharCount="50000000" />
      <security mode="None"></security>
    </binding>
  </netTcpBinding>

But when I add Service Reference to WebSite project, it updates the web.config with default values. 但是,当我将Service Reference添加到WebSite项目时,它将使用默认值更新web.config。 And then I receive this error: The maximum message size quota for incoming messages (65536) has been exceeded. 然后,我收到此错误:超出了传入邮件的最大邮件大小配额(65536)。 To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element. 要增加配额,请在适当的绑定元素上使用MaxReceivedMessageSize属性。

I reckon, updating website config file with the settings in service congig will resolve this error. 我认为,使用服务配置中的设置更新网站配置文件将解决此错误。

But I wonder if I need to change these setting manually everytime I add service reference? 但是我想知道是否每次添加服务参考时都需要手动更改这些设置?

Yes unfortunately, when adding the Service Reference, the settings from the server will not be transmitted to the client. 是的,很遗憾,添加服务参考时,服务器中的设置不会传输到客户端。 You'll have to set those manually. 您必须手动设置这些设置。

What you might be able to do is using the "Update Service Reference" menu command instead of always creating a new service reference. 您可能能够使用“更新服务参考”菜单命令,而不是总是创建新的服务参考。 This might preserve your settings (not sure - I never use it myself). 这可能会保留您的设置(不确定-我从不亲自使用它)。

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

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