消息队列 长度不能小于 0。 参数名: length

moonwrong 2013-05-27 03:32:11
长度不能小于 0。
参数名: length

说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.ArgumentOutOfRangeException: 长度不能小于 0。
参数名: length

源错误:

执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。

堆栈跟踪:

麻烦各位给看一下,谢谢
[ArgumentOutOfRangeException: 长度不能小于 0。
参数名: length]
System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) +7495991
System.String.Substring(Int32 startIndex, Int32 length) +11
Maticsoft.Web.inc.top.Bind() in D:\work\ThreelayerSolution\Web\inc\top.ascx.cs:39
Maticsoft.Web.inc.top.Page_Load(Object sender, EventArgs e) in D:\work\ThreelayerSolution\Web\inc\top.ascx.cs:22
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
...全文
629 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
coobai 2013-05-27
  • 打赏
  • 举报
回复
报错似乎是在 Substring 的时候 第2个参数截取的长度 超过了
好基友一被子 2013-05-27
  • 打赏
  • 举报
回复
你直接调试 之后把出错的截图上来吧。。。
moonwrong 2013-05-27
  • 打赏
  • 举报
回复
引用 8 楼 qy1116 的回复:
[quote=引用 7 楼 moonwrong 的回复:] [quote=引用 6 楼 qy1116 的回复:] [quote=引用 5 楼 moonwrong 的回复:] [quote=引用 3 楼 qy1116 的回复:] [quote=引用 2 楼 moonwrong 的回复:] [quote=引用 1 楼 cc5258 的回复:] 先判断下吧 if(length>0) 然后在执行啊
加上了判断了,但是还是报错[/quote] 把你出错的代码贴出来。。。[/quote] void Bind() { DataSet ds = new Maticsoft.BLL.Tab_GuangGao().GetList(8, " type='3'", " addTime desc"); String pics = null; String links = null; String texts = null; foreach (DataRow row in ds.Tables[0].Rows) { pics += row["address"] + "|"; links += row["link"] + "|"; texts += row["title"] + "|"; } if(pics.Length >= 1 && texts.Length>= 1 && links.Length>= 1) { img_hidden.Value = pics.Substring(0, pics.Length); title_hidden.Value = texts.Substring(0, texts.Length); link_hidden.Value = links.Substring(0, links.Length); } } [/quote] String pics = null; String links = null; String texts = null; 这里定义改成String pics = ""; String links = ""; String texts = "" 再试试[/quote]改过来试了,还是不行,[/quote] 额, String pics = null; String 改成小写string[/quote] 我发现删掉这个文件还是报一样的错,而且这个路径D:\work\ThreelayerSolution\Web\inc\top.ascx.cs也和服务器上面的路径不一致
好基友一被子 2013-05-27
  • 打赏
  • 举报
回复
引用 7 楼 moonwrong 的回复:
[quote=引用 6 楼 qy1116 的回复:] [quote=引用 5 楼 moonwrong 的回复:] [quote=引用 3 楼 qy1116 的回复:] [quote=引用 2 楼 moonwrong 的回复:] [quote=引用 1 楼 cc5258 的回复:] 先判断下吧 if(length>0) 然后在执行啊
加上了判断了,但是还是报错[/quote] 把你出错的代码贴出来。。。[/quote] void Bind() { DataSet ds = new Maticsoft.BLL.Tab_GuangGao().GetList(8, " type='3'", " addTime desc"); String pics = null; String links = null; String texts = null; foreach (DataRow row in ds.Tables[0].Rows) { pics += row["address"] + "|"; links += row["link"] + "|"; texts += row["title"] + "|"; } if(pics.Length >= 1 && texts.Length>= 1 && links.Length>= 1) { img_hidden.Value = pics.Substring(0, pics.Length); title_hidden.Value = texts.Substring(0, texts.Length); link_hidden.Value = links.Substring(0, links.Length); } } [/quote] String pics = null; String links = null; String texts = null; 这里定义改成String pics = ""; String links = ""; String texts = "" 再试试[/quote]改过来试了,还是不行,[/quote] 额, String pics = null; String 改成小写string
moonwrong 2013-05-27
  • 打赏
  • 举报
回复
引用 6 楼 qy1116 的回复:
[quote=引用 5 楼 moonwrong 的回复:] [quote=引用 3 楼 qy1116 的回复:] [quote=引用 2 楼 moonwrong 的回复:] [quote=引用 1 楼 cc5258 的回复:] 先判断下吧 if(length>0) 然后在执行啊
加上了判断了,但是还是报错[/quote] 把你出错的代码贴出来。。。[/quote] void Bind() { DataSet ds = new Maticsoft.BLL.Tab_GuangGao().GetList(8, " type='3'", " addTime desc"); String pics = null; String links = null; String texts = null; foreach (DataRow row in ds.Tables[0].Rows) { pics += row["address"] + "|"; links += row["link"] + "|"; texts += row["title"] + "|"; } if(pics.Length >= 1 && texts.Length>= 1 && links.Length>= 1) { img_hidden.Value = pics.Substring(0, pics.Length); title_hidden.Value = texts.Substring(0, texts.Length); link_hidden.Value = links.Substring(0, links.Length); } } [/quote] String pics = null; String links = null; String texts = null; 这里定义改成String pics = ""; String links = ""; String texts = "" 再试试[/quote]改过来试了,还是不行,
好基友一被子 2013-05-27
  • 打赏
  • 举报
回复
引用 5 楼 moonwrong 的回复:
[quote=引用 3 楼 qy1116 的回复:] [quote=引用 2 楼 moonwrong 的回复:] [quote=引用 1 楼 cc5258 的回复:] 先判断下吧 if(length>0) 然后在执行啊
加上了判断了,但是还是报错[/quote] 把你出错的代码贴出来。。。[/quote] void Bind() { DataSet ds = new Maticsoft.BLL.Tab_GuangGao().GetList(8, " type='3'", " addTime desc"); String pics = null; String links = null; String texts = null; foreach (DataRow row in ds.Tables[0].Rows) { pics += row["address"] + "|"; links += row["link"] + "|"; texts += row["title"] + "|"; } if(pics.Length >= 1 && texts.Length>= 1 && links.Length>= 1) { img_hidden.Value = pics.Substring(0, pics.Length); title_hidden.Value = texts.Substring(0, texts.Length); link_hidden.Value = links.Substring(0, links.Length); } } [/quote] String pics = null; String links = null; String texts = null; 这里定义改成String pics = ""; String links = ""; String texts = "" 再试试
moonwrong 2013-05-27
  • 打赏
  • 举报
回复
引用 3 楼 qy1116 的回复:
[quote=引用 2 楼 moonwrong 的回复:] [quote=引用 1 楼 cc5258 的回复:] 先判断下吧 if(length>0) 然后在执行啊
加上了判断了,但是还是报错[/quote] 把你出错的代码贴出来。。。[/quote] void Bind() { DataSet ds = new Maticsoft.BLL.Tab_GuangGao().GetList(8, " type='3'", " addTime desc"); String pics = null; String links = null; String texts = null; foreach (DataRow row in ds.Tables[0].Rows) { pics += row["address"] + "|"; links += row["link"] + "|"; texts += row["title"] + "|"; } if(pics.Length >= 1 && texts.Length>= 1 && links.Length>= 1) { img_hidden.Value = pics.Substring(0, pics.Length); title_hidden.Value = texts.Substring(0, texts.Length); link_hidden.Value = links.Substring(0, links.Length); } }
cc5258 2013-05-27
  • 打赏
  • 举报
回复
代码呢? 判断前再加个是否null
好基友一被子 2013-05-27
  • 打赏
  • 举报
回复
引用 2 楼 moonwrong 的回复:
[quote=引用 1 楼 cc5258 的回复:] 先判断下吧 if(length>0) 然后在执行啊
加上了判断了,但是还是报错[/quote] 把你出错的代码贴出来。。。
moonwrong 2013-05-27
  • 打赏
  • 举报
回复
引用 1 楼 cc5258 的回复:
先判断下吧 if(length>0) 然后在执行啊
加上了判断了,但是还是报错
cc5258 2013-05-27
  • 打赏
  • 举报
回复
先判断下吧 if(length>0) 然后在执行啊

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧