开发者

WCF Service - MaxReceivedMessageSize Error

开发者 https://www.devze.com 2022-12-16 06:23 出处:网络
I have my WCF Service hosted in Windows Service. The client application is a website project to which I add Service reference.

I have my WCF Service hosted in Windows Service. The client application is a website project to which I add Service reference.

Now, Windows Service configuration file has the right settings for 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. And then I receive this error: The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

I reckon, updating website config file with the settings in service congig will r开发者_开发知识库esolve 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).

0

精彩评论

暂无评论...
验证码 换一张
取 消