我正在尝试正确设置我的App.Config以允许我的NetTcp服务返回大于65536的字符串,因为我在下面收到此错误
传入邮件的最大邮件大小限额(65536) 超标。要增加配额,请使用MaxReceivedMessageSize 适当的绑定元素上的属性。
到目前为止,这是我尝试过的但它不起作用,我希望有人可以指出我的错误
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service name="NetTcpSHWS.Service1" behaviorConfiguration="NetTcpSHWS.Service1Behavior">
<host>
<baseAddresses>
<add baseAddress = "net.tcp://localhost:8732/Design_Time_Addresses/NetTcpSHWS/Service1/" />
</baseAddresses>
</host>
<endpoint name="NetRcpEndPoint" address ="" binding="netTcpBinding" bindingConfiguration="netMyConfig" contract="NetTcpSHWS.IService1">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint name="NetTcpMetadataPoint" address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="NetTcpSHWS.Service1Behavior">
<serviceMetadata httpGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="False" />
<dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483646" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="netMyConfig"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
transferMode="Buffered">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
</configuration>
这只是一个测试应用
答案 0 :(得分:1)
添加bindingConfiguration
:
<endpoint name="NetRcpEndPoint" bindingConfiguration="myConfiguration" ... >
<netTcpBinding>
<binding name="myConfiguration" ...
</binding>
</netTcpBinding>
如果不这样做,将不使用您的绑定配置(将使用默认配置)。