在 WP8 中下载文件时出现 OutOfMemoryException [英] OutOfMemoryException while downloading files in WP8

查看:24
本文介绍了在 WP8 中下载文件时出现 OutOfMemoryException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试从 Windows 移动应用程序下载大文件(大小 >170 MB)时,我收到此异常

While i am trying to download the large files ( of size >170 MB ) from windows mobile application i am getting this exception

System.Windows.ni.dll 中发生类型为System.OutOfMemoryException"的未处理异常

An unhandled exception of type 'System.OutOfMemoryException' occurred in System.Windows.ni.dll

附加信息:内存不足,无法继续执行程序.

Additional information: Insufficient memory to continue the execution of the program.

奇怪的是我只收到少数文件的异常.这是我用来下载文件的代码

The strange thing is i am getting the exception only for few files. This is the code i used to download the file

       hpubDownloader = new WebClient();
        hpubDownloader.OpenReadCompleted += (s, e) =>
        {
           //process response
        };
        hpubDownloader.DownloadProgressChanged += (s, e) =>
        {
            int value = e.ProgressPercentage;
            //show progress percentage , and it shows till 98 % after that it goes to exception App_Unhandled exception
        };
        hpubDownloader.OpenReadAsync(url);

这可能是什么原因?我没有得到关于异常的任何其他详细信息,甚至我试图将 Try-catch 块放在 webclient 下载代码中,但这也没有触发.可能的原因是什么?

What might be the reaosn for this ? I am not getting any other details about exception and even i tried to put Try- catch block in webclient download code , but thats also not firing . What might be the possible reasons?

推荐答案

关注这篇 MSDN 文章了解更多信息 - Windows Phone 8 的应用内存限制

Follow this MSDN article for more information - App memory limits for Windows Phone 8

这篇关于在 WP8 中下载文件时出现 OutOfMemoryException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆