最近要做一个上传功能的WCF,20M 70M都测试成后,但是在测试130M的时候,却跳出

"Failed to allocate a managed memory buffer of 268435456 bytes."

错误,

wcf web.config
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="VODServiceBinding" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" messageEncoding="Mtom">
                    <readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647"/>
                </binding>
            </basicHttpBinding>
        </bindings>
        <services>
            <service behaviorConfiguration="VOD.VODServiceBehavior"
                name="VOD.VODService">
                <endpoint address="" binding="basicHttpBinding" bindingConfiguration="VODServiceBinding" contract="VOD.IVODService" />
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="VOD.VODServiceBehavior">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
            <dataContractSerializer maxItemsInObjectGraph="2147483647" ignoreExtensionDataObject="true" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>
client web.config
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IVODService" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:30:00" sendTimeout="00:30:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
                    messageEncoding="Mtom" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://xxxxxx.com/VODService.svc" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_IVODService" contract="VODService.IVODService"
                name="BasicHttpBinding_IVODService" />
        </client>
    </system.serviceModel>

然后从MSDN的论坛里找到了一种方法,就是分段把文件内容传到服务器上,追加到文件结尾

Code
                    byte[] buffer = new byte[65000];
                    int bytesRead = 0;

                    VODService.IVODService proxy = client.ChannelFactory.CreateChannel();

                    while ((bytesRead = fuUpload.PostedFile.InputStream.Read(buffer, 0, 65000)) > 0)
                    {
                        video.Data = buffer;
                        video.Offset = 0;
                        video.Count = bytesRead;
                        proxy.UploadVideo(video);
                    }

                    client.ChannelFactory.Close();

我想可能是一次传的文件放在内存里太大了

希望对大家有帮助

转载于:https://www.cnblogs.com/Death/archive/2008/08/12/1266078.html

百思不得其解的Failed to allocate a managed memory buffer of 268435456 bytes.错误解决相关推荐

  1. [Vue warn]: Failed to mount component: template or render function not defined. 错误解决方法

    [Vue warn]: Failed to mount component: template or render function not defined. 错误解决方法 参考文章: (1)[Vue ...

  2. Altium Designer20 出现Failed to add class member:xxx 和 Unknown Pin 错误解决办法

    Failed to add class member错误解决办法 今天用AD20转换文件时出现了这个情况Failed to add class member结果不能正常导入到PCB文件.如图. 网上很 ...

  3. linux apr文件解压失败,Apache编译安装提示configure: error: APR not found错误解决方法...

    在配置Apache的时候,出现configure: error: APR not found错误 原因是缺少一些依赖包,安装这些依赖包就行了 下载依赖包,注意我这里下载的与参考链接上的有些不同,安装上 ...

  4. Allowed memory size of 268435456 bytes exhausted (tried to allocate 262144 bytes)

    命名空间下的 redis 坑

  5. 百思不得其解,一个钻石玩家可以短时间上王者?因为猎游?

    要不是亲身体验自己,也不会相信自己的段位,竟然可以短时间之内直接跨越星耀直接上王者,当然这里面就是连胜给我带来的福利,因为在游戏里面我不得不说,有一个强大的队友比什么都来得爽快,因为玩王者荣耀的时候我 ...

  6. 解决Android 启动模拟器是出现“Failed to allocate memory: 8”错误提示

    Android 启动模拟器是出现" Failed to allocate memory: 8"错误,模拟器无法启动,如下: [2012-11-26 13:40:12 - TestS ...

  7. React setStats数组不更新,百思不得其解。

    楼楼今日遇到个坑爹的问题. 就是 this.setStats({}) 对 this.stats 不更新问题 问题是这样的 constructor(props) {super(props);this.s ...

  8. Android之java.lang.OutOfMemoryError: Failed to allocate a ** byte allocation with **free bytes and 2M

    1 问题 glide加载图片出现oom java.lang.OutOfMemoryError: Failed to allocate a 23970828 byte allocation with 2 ...

  9. 刚接触电子时,有过哪些百思不得其解的问题?

    青少年时期,刚接触电子时,出于好奇,对这方面的东西也比较关注,但同时也衍生了一些百思不得其解的疑问,比如... 01 物理书里说大地是导体,那为什么我的小灯珠却不亮!? 02 初三时学了物理的电学,知 ...

最新文章

  1. Automatically highlight current page in menu via Javascript
  2. 中国人工智能学会通讯——智能系统测评:挑战和机遇
  3. 华为Mate30、iPhone11、小米9 Pro 到底怎么选?
  4. iOS 块的简单理解
  5. 面试—每日一题(4)
  6. .net平台调用(P/Invoking)查询网站
  7. 删除数据所有的表和存储过程
  8. Vectorworks 2022 SP2 for mac(首选3D建筑设计软件)
  9. 联想自带Y空间软件最好用的版本-可录屏无其它提示
  10. Unix编程艺术-翻译-开篇
  11. 头脑极度开放:前额皮层大战杏仁核
  12. panic 和 recover
  13. 超千万人同时在线,抖音快手,是怎么抗住高并发?
  14. Delphi 汉字转拼音
  15. 马虎词汇教程16-20(转载)
  16. Java 内部类之匿名内部类
  17. 微信11个超级实用的小技巧,值得一试
  18. selenium三种等待时间之强制等待
  19. QGIS 3.14|地震数据动画效果实战(二)动画设置篇
  20. 世上只有一种英雄主义,就是在认清生活真相之后依然热爱生活。

热门文章

  1. 斯密斯圆图-学习笔记
  2. 2021安庆市地区高考成绩排名查询,安庆中学排名前十名,2021年安庆中学排名一览表...
  3. 2019-10-28 超大文本打开工具PilotEdit
  4. 2021-912--51单片机串口通信--SCON方式1
  5. MySQL基础学习③数据库准备工作,导入官方employees数据库
  6. HTML元素中的属性2(路径详解)—零基础自学网页制作
  7. 安霸S5L通过usb虚拟网卡共享网络功能
  8. 【NLP】Prompt+对比学习,更好地学习句子表征
  9. 智能语音应用开发之DPL2.0高级特性
  10. 不积跬步无以至千里,不积小流无以成江海----SAX读取xml