解决WCF The maximum nametable character count quota (16384) has been exceeded whil

今天将客户端程序引用之前创建的一个方法相当多的services的时候碰到如下一个错误,

 

Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:9997/DataService/mex'.
There is an error in the XML document.
There is an error in the XML document.
The maximum nametable character count quota (16384) has been exceeded while reading XML data. The nametable is a data structure used to store strings encountered during XML processing - long XML documents with non-repeating element names, attribute names and attribute values may trigger this quota. This quota may be increased by changing the MaxNameTableCharCount property on the XmlDictionaryReaderQuotas object used when creating the XML reader.
If the service is defined in the current solution, try building the solution and adding the service reference again.
 

当前的endpoint配置

<service behaviorConfiguration="MyBehavior" name="XXX.XXXX.DataService">
       <endpoint address="" binding="netTcpBinding" name="NetTcpEndPoint" contract="XXX.XXXX.XXXXXXX.XXXX.XXXXXXXXXXXXXX.IDataService"/>
       <endpoint address="mex" binding="mexTcpBinding" name="NetTcpMetadataPoint" contract="IMetadataExchange"/>
       <host>
        <baseAddresses>
         <add baseAddress="net.tcp://localhost:9997/DataService/"/>
        </baseAddresses>
       </host>
      </service>
 

 

解决办法:

1.在service的app.config的<system.serviceModel>节电下创建一个新的bindings, 使用netTcpBinding来代替mexTcpBinding:

<bindings>
      <netTcpBinding>
        <binding name="GenericBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
          <security mode="None"/>
        </binding>
      </netTcpBinding>
</bindings>
 

 

2.将之前的endpoint设置改成

<service behaviorConfiguration="MyBehavior" name="XXX.XXXX.DataService">
       <endpoint address="" binding="netTcpBinding" name="NetTcpEndPoint" bindingConfiguration="GenericBinding" contract="XXX.XXXX.XXXXXXX.XXXX.XXXXXXXXXXXXXX.IDataService"/>
       <endpoint address="mex" binding="netTcpBinding" name="NetTcpMetadataPoint" bindingConfiguration="GenericBinding" contract="IMetadataExchange"/>
       <host>
        <baseAddresses>
         <add baseAddress="net.tcp://localhost:9997/DataService/"/>
        </baseAddresses>
       </host>
      </service>
 

 

3.修改Client端的app.config 或者在"C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE" 下的devenv.exe.config(修改这个的话需要重启VS)中添加.

添加

<system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="GenericBinding" maxBufferPoolSize="2147483647"
          maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None" />
        </binding>
      </netTcpBinding>
    </bindings>
    <client>
      <endpoint binding="netTcpBinding" bindingConfiguration="GenericBinding"
        contract="IMetadataExchange" name="net.tcp" />
    </client>
  </system.serviceModel>
 

 

4.之后再重新Add Service References就正常了.

 

我的原文连接 http://www.markgoo.com/?p=73


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值