代码改变世界

vs引用更新wcf mextcpbinding服务错误

2011-04-26 10:08  Fred-Xu  阅读(1083)  评论(0编辑  收藏  举报

我的一个service contract有大概100个方法,host使用的是tcp.ip绑定协议,项目在更新引用服务的时候报错,提示队列不能超过64k。查询了下msdn论坛,找到了解决方法:

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

<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ServerBehavior">
<serviceMetadata />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="SimpleClientServer.HelloService" behaviorConfiguration="ServerBehavior">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:31000/SimpleServer" />
</baseAddresses>
</host>
<!--bindingConfiguration="default"-->
<endpoint address=""
binding
="netTcpBinding"
bindingConfiguration
="myTcp"
contract
="SimpleClientServer.IBigHelloService" />
<endpoint address="mex"
binding
="netTcpBinding"
bindingConfiguration
="myTcp"
contract
="IMetadataExchange" />
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="myTcp" maxBufferPoolSize="60000000" maxBufferSize="60000000" maxReceivedMessageSize="60000000" >
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength
="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
</configuration>

创建一个新的svcutil.exe.config文件,在本地目录覆盖原有的svcutil.exe.config文件。

<configuration>

<system.serviceModel>

<client>

<!-- the name should match the required scheme of the Metadata Exchange endpoint

and the contract should be "IMetadataExchange"
-->

<endpoint name="net.tcp"

binding
="netTcpBinding"

bindingConfiguration
="myTcp"

contract
="IMetadataExchange" />

</client>

<bindings>

<netTcpBinding>

<binding name="myTcp" maxBufferPoolSize="60000000" maxBufferSize="60000000" maxReceivedMessageSize="60000000" >

<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"

maxArrayLength
="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />

</binding>

</netTcpBinding>

</bindings>

</system.serviceModel>

</configuration>


更新引用服务,这下ok啦。

如果是在vs中直接引用wcf服务,当服务的方法超过一定数量后更新服务时候会报错。

解决方法很简单,修改devenv.exe.config文件即可:

<system.net>
<settings>
<ipv6 enabled="true"/>
</settings>
</system.net>
 <!--增加system.serviceModel节点-->
<system.serviceModel>
<client>
<endpoint name="net.tcp" binding="netTcpBinding" bindingConfiguration="bindConf" contract="IMetadataExchange" />
</client>
<bindings>
<netTcpBinding>
<binding name="bindConf" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>

参考:http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/d7e36a08-5835-42f8-8eec-8e005cb063c9