如何在运行应用程序之前将app.config文件中的maxReceivedMessageSize和maxBufferSize参数增加到2000000.
我必须遵循以下代码:
BasicHttpBinding binding = new BasicHttpBinding ();
Uri baseAddress = new Uri ("URL.svc");
EndpointAddress endpointAddress = new EndpointAddress (baseAddress);
var myChannelFactory = new ChannelFactory<IMyInterface> (binding, endpointAddress);
IMyInterface client = null;
try
{
client = myChannelFactory.CreateChannel ();
var a = client.WsFunction ("XXXXXX");
((ICommunicationObject)client).Close ();
}
catch
{
if (client != null)
{
((ICommunicationObject)client).Abort ();
}
}
Run Code Online (Sandbox Code Playgroud)
其中"IMyInterface"是我的WS实现的接口..例如:
[ServiceContract]
public interface IMyInterface
{
[OperationContract]
Result WsFunction1 (string param);
[OperationContract]
Result WsFunction2 (string param);
[OperationContract]
Result WsFunction3 (string param);
}
Run Code Online (Sandbox Code Playgroud)
它返回如下内容:
[DataContract]
public …Run Code Online (Sandbox Code Playgroud) 我最近在wcf REST服务的web.config文件中进行了更改,我刚刚添加了maxBufferSize="10485760"属性.请在下面找到代码段...
<wsHttpBinding>
<binding name="WSHttpBinding_IService" closeTimeout="00:04:00"
openTimeout="00:04:00" receiveTimeout="00:04:00" sendTimeout="00:04:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode=
"StrongWildcard" maxBufferSize="10485760" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8"
useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:04:00" enabled="false" />
</binding>
</wsHttpBinding>
Run Code Online (Sandbox Code Playgroud)
进行更改后,应用程序无法正常工作,它会抛出以下异常.
配置错误说明:处理为此请求提供服务所需的配置文件时发生错误.请查看下面的具体错误详细信息并相应地修改配置文件.分析器错误消息:无法识别的属性'maxBufferSize'.请注意,属性名称区分大小写.
如果有人可以提供帮助,那就太好了.