Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WCF maxBytesPerRead限制为4096_C#_Wcf_Wcf Binding - Fatal编程技术网

C# WCF maxBytesPerRead限制为4096

C# WCF maxBytesPerRead限制为4096,c#,wcf,wcf-binding,C#,Wcf,Wcf Binding,我正在蒸汽模式下使用基本WCF web服务从服务器下载文件 我已将服务器端的绑定指定为 <basicHttpBinding> <binding name="DBUpdateServiceBinding" closeTimeout="23:59:59" openTimeout="23:59:59" receiveTimeout="23:59:59" sendTimeout="23:59:59" maxRecei

我正在蒸汽模式下使用基本WCF web服务从服务器下载文件

我已将服务器端的绑定指定为

     <basicHttpBinding>
        <binding name="DBUpdateServiceBinding" closeTimeout="23:59:59"
           openTimeout="23:59:59" receiveTimeout="23:59:59" sendTimeout="23:59:59"
           maxReceivedMessageSize="10067108864" messageEncoding="Mtom"
           transferMode="Streamed">
           <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="8192" maxNameTableCharCount="16384" />
        </binding>
     </basicHttpBinding>

我的客户端绑定xml看起来像

  <bindings>
     <basicHttpBinding>
        <binding name="ws" closeTimeout="23:59:59" openTimeout="23:59:59"
           receiveTimeout="23:59:59" sendTimeout="23:59:59" maxReceivedMessageSize="10067108864"
           messageEncoding="Mtom" transferMode="Streamed">
           <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="8192" maxNameTableCharCount="16384" />
           <security>
              <transport realm="" />
           </security>
        </binding>
     </basicHttpBinding>
  </bindings>

我正在尝试使用下载文件

   byte[] buffer = new byte[32768];
   while (true)
   {
      int read = serverStream.Read(buffer, 0, buffer.Length);
      if (read <= 0)
         break;
      fs.Write(buffer, 0, read);
   }
byte[]buffer=新字节[32768];
while(true)
{
int read=serverStream.read(buffer,0,buffer.Length);

如果(Read

除非您有非常特定的安全性要求,否则您可能需要考虑将最大大小设置为It32.Max值。这将为您节省一些调试时间。如果需要,将其调整为更合理的值。

您确信这些绑定配置是否真正被您的服务和客户端端点使用??是的,我是SU。关于这一点,没有定义其他配置。它是web.config中的maxRequestLength吗?您的客户端创建代码是什么样子的?如果您没有调用默认构造函数,您可能没有使用app.config中指定的配置。这并不能回答无论您设置什么,maxBytesPerRead都会停留在4096的问题it to(与流媒体和MTOM一起)