- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
在 Silverlight 上下载非常大的文件 (>2GB) 时,我遇到了一个问题。我的应用程序是一个以提升的权限运行的浏览器外下载管理器。
当文件达到一定的数据量(2GB)时,抛出如下异常:
System.ArgumentOutOfRangeException was caught
Message=Specified argument was out of the range of valid values.
Parameter name: count
StackTrace:
in MS.Internal.InternalNetworkStream.BeginRead(Byte[] buffer, Int32 offset, Int32 count, AsyncCallback callback, Object state)
in MS.Internal.InternalNetworkStream.Read(Byte[] buffer, Int32 offset, Int32 count)
in MySolution.DM.Download.BeginResponseCallback(IAsyncResult ar)
InnerException:
Null
我唯一的线索是 this site , 谁展示了 BeginCode
的实现。此异常仅在 count
为 < then 0 时发生。
我的代码
/* "Target" is a File object. "source" is a Stream object */
var buffer = new byte[64 * 1024];
int bytesRead;
Target.Seek(0, SeekOrigin.End); // The file might exists when resuming a download
/* The exception throws from inside "source.Read" */
while ((bytesRead = source.Read(buffer, 0, buffer.Length)) > 0)
{
Target.Write(buffer, 0, bytesRead);
_fileBytes = Target.Length;
Deployment.Current.Dispatcher.BeginInvoke(() => { DownloadPercentual = Double.Parse(Math.Round((decimal)(_fileBytes / (_totalSize / 100)), 5).ToString()); });
}
Target.Close();
logFile.Close();
错误发生在不同类型的文件上,它们来自 Amazon S3 上的公共(public)存储桶。 (使用常规的 http 请求)。
最佳答案
我搜索了一下,看起来这是 Silverlight 中的一个已知限制。一种可能的解决方法是使用 Range header 分多个部分执行下载,每个部分小于 2GB。
关于c# - 通过 Stream.Read 下载文件时出现 ArgumentOutOfRangeException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12063142/
我在使用 Ajax Control Toolkit 日历扩展器的文本框上遇到错误,我使用的是 Microsoft Edge、IE11、Chrome: Uncaught Sys.ArgumentOutO
嘿嘿, 我需要一些帮助来解决我的应用程序不断遇到的异常, 异常在这段代码中触发 Map mapView = new Map() { CredentialsPro
当我写作时: throw new ArgumentOutOfRangeException("") 将插入符号放在引号之间,然后按 Ctrl+Space 打开 intellisense 实际上有一些作用
我有一个 if 语句,说明如果网页有特定文本,则删除列表框中的所选项目并向下迭代到下一个。 我写了一些代码,但当我尝试它时,我不断得到: ArgumentOutOfRangeException was
我遇到了一些奇怪的行为...当我在 ThreadTest 方法中遍历 dummyText List 时,我得到了一个索引范围异常 (ArgumentOutOfRangeException),但如果我删
我正在编写 WinForms C# 程序。 我正在尝试关闭除主窗体 FrmMain 之外的所有窗体。 我必须隐藏我的主窗体。 我通过打开两个表单生成了这个。一个是我的主窗体,另一个是用 ShowDia
当我真的不确定为什么时,我得到一个 ArgumentOutOfRangeException。 Task[] downloadTasks = new Task[music.Count]; for (in
这个“问题”可能很难测试/重现,对于那些安装了英语作为唯一语言的 Windows 版本的人来说。我在安装了“丹麦语(丹麦)”(“da-DK” 文化)、.NET 4.5 版的 Windows 7 机器上
它在 For 循环的中间抛出一个 ArgumentOutOfRangeException,请注意我删除了 for 循环的其余部分 for (int i = 0; i Direct_Assoc;
对于我的生活,我无法弄清楚为什么这行代码: var literalExpressionSyntax = Syntax.LiteralExpression(SyntaxKind.Charact
我正在尝试在 C# 控制台应用程序中设置控制台窗口的大小。我收到一个 ArgumentOutOfRangeException 消息: The value must be less than the c
我对 Xamarin.Forms 还是很陌生。我在出现的主页上有一个非常简单的功能 async public Task BaseAppearing() { if (UserID
我有一些代码,执行时会抛出IndexOutOfRangeException,说: Index was outside the bounds of the array. 这是什么意思,我该怎么办? 根据
我有一些代码,执行时会抛出IndexOutOfRangeException,说: Index was outside the bounds of the array. 这是什么意思,我该怎么办? 根据
使用多个查询,如下面的代码所示,我得到以下异常: An exception of type 'System.ArgumentOutOfRangeException' - Specified argum
我有一些代码,执行时会抛出一个IndexOutOfRangeException,说: 指数数组的边界之外。 这是什么意思,我该怎么办? 根据使用的类,它也可以是ArgumentOutOfRange
我有一些代码,执行时会抛出一个IndexOutOfRangeException,说: 指数数组的边界之外。 这是什么意思,我该怎么办? 根据使用的类,它也可以是ArgumentOutOfRange
我在编程时遇到了这个错误,经过了一些调试、谷歌搜索过程,但我找不到问题所在,我请求你的帮助! MessageBox.Show(dataGridView1.RowCount.ToStri
每当我尝试打开页面时,我总是收到此“需要 ArgumentOutOfRange 异常非负数,参数名称:索引”,但我似乎无法弄清楚负数出现的位置/方式。提前谢谢大家!! var months = dat
当我循环遍历列表时,我的代码抛出一个超出范围的错误,但我不知道为什么。这是我的代码: for(int neighborCounter = neighborList.Count - 1;
我是一名优秀的程序员,十分优秀!