我有一个大型类,其中有许多函数作为WCF服务公开,它也有一个mex endpiont。现在,当我尝试在Visual Studio 2010中添加对该服务的引用时,我收到以下错误:
除了减少方法计数之外,我还能做些什么来使这个错误消失吗?
这是我用于mex端点的代码:
// Check to see if the service host already has a ServiceMetadataBehavior
ServiceMetadataBehavior smb = svh.Description.Behaviors.Find<ServiceMetadataBehavior>();
// If not, add one
if (smb == null)
smb = new ServiceMetadataBehavior();
//smb.HttpGetEnabled = true;
smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
svh.Description.Behaviors.Add(smb);
// Add MEX endpoint
svh.AddServiceEndpoint(
ServiceMetadataBehavior.MexContractName,
MetadataExchangeBindings.CreateMexTcpBinding(),
location+"/mex"
);
答案 0 :(得分:3)
您可以使用配置文件中readerQuota节点上的maxNameTableCharCount属性覆盖它。
这是&lt; readerQuote&gt;文件:http://msdn.microsoft.com/en-us/library/ms731325.aspx
这是自动生成的客户端配置的示例。默认值为16384。
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="YOUR_NAME" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="268438456" maxBufferPoolSize="524288" maxReceivedMessageSize="268438456"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="Basic" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="YOUR_ADDRESS" binding="basicHttpBinding"
bindingConfiguration="YOUR_ENDPOINT" contract="YOUR_CONTRACT"
name="YOUR_NAME" />
</client>
</system.serviceModel>