[Winform]使用日志记录下来的错误,要如何分析问题出在哪.

TonyWu66 2009-01-08 10:42:58
请教各位前辈:
以下是一段错误记录,请问我怎么才知道问题出在哪.如果这些信息不足以找出问题点的话,我还需要记录哪些信息?谢谢!

电脑名称:E*****
用户名称:R*****\u***
IP地址:192.168.1.*
物理内存:519553024
发生时间2009-1-6 16:34:23:
错误信息:指定的参数已超出有效值的范围。
参数名: rowIndex
类名:DataGridView
方法名:GetCellDisplayRectangle
StackTrace: 在 System.Windows.Forms.DataGridView.GetCellDisplayRectangle(Int32 columnIndex, Int32 rowIndex, Boolean cutOverflow)
在 System.Windows.Forms.DataGridView.GetCellAdjustedDisplayRectangle(Int32 columnIndex, Int32 rowIndex, Boolean cutOverflow)
在 System.Windows.Forms.DataGridView.InvalidateCellPrivate(Int32 columnIndex, Int32 rowIndex)
在 System.Windows.Forms.DataGridView.OnCellCommonChange(Int32 columnIndex, Int32 rowIndex)
在 System.Windows.Forms.DataGridView.DataGridViewDataConnection.ProcessListChanged(ListChangedEventArgs e)
在 System.Windows.Forms.DataGridView.DataGridViewDataConnection.currencyManager_ListChanged(Object sender, ListChangedEventArgs e)
在 System.Windows.Forms.CurrencyManager.OnListChanged(ListChangedEventArgs e)
在 System.Windows.Forms.CurrencyManager.CancelCurrentEdit()
在 System.Windows.Forms.DataGridView.DataGridViewDataConnection.CancelRowEdit(Boolean restoreRow, Boolean addNewFinished)
在 System.Windows.Forms.DataGridView.DataGridViewDataConnection.OnRowValidating(DataGridViewCellCancelEventArgs e)
在 System.Windows.Forms.DataGridView.OnRowValidating(DataGridViewCell& dataGridViewCell, Int32 columnIndex, Int32 rowIndex)
在 System.Windows.Forms.DataGridView.OnValidating(CancelEventArgs e)
在 System.Windows.Forms.Control.PerformControlValidation(Boolean bulkValidation)
在 System.Windows.Forms.ContainerControl.ValidateThroughAncestor(Control ancestorControl, Boolean preventFocusChangeOnError)
在 System.Windows.Forms.ContainerControl.ValidateInternal(Boolean checkAutoValidate, Boolean& validatedControlAllowsFocusChange)
在 System.Windows.Forms.ContainerControl.ValidateInternal(Boolean checkAutoValidate, Boolean& validatedControlAllowsFocusChange)
在 System.Windows.Forms.ContainerControl.Validate(Boolean checkAutoValidate)
在 System.Windows.Forms.Form.WmClose(Message& m)
在 System.Windows.Forms.Form.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
...全文
521 23 打赏 收藏 转发到动态 举报
写回复
用AI写文章
23 条回复
切换为时间正序
请发表友善的回复…
发表回复
syhwork 2011-02-28
  • 打赏
  • 举报
回复
我也碰到同样的问题了,这个错误是微软的bug吗?
如果是的话,该怎么解决呢?
打.NET补丁吗?


hanjoe109 2009-04-10
  • 打赏
  • 举报
回复
我也遇到問題了
System.InvalidOperationException: Operation is not valid due to the current state of the object.
也是來回點擊時報的錯
TonyWu66 2009-01-16
  • 打赏
  • 举报
回复
此问题未彻底解决,结贴!谢谢各位
GTX280 2009-01-08
  • 打赏
  • 举报
回复
错误信息:指定的参数已超出有效值的范围。
参数名: rowIndex

看堆栈似乎是修改某行的时候关闭窗口出错,找找代码中操作DataGridView的地方
TonyWu66 2009-01-08
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 acns 的回复:]
引用 4 楼 tonyepaper 的回复:
但上面的这些方法我都没调用.而且没出现我自己的类,所以不知道问题出在哪,应该怎么改.大家都是怎么处理客户端出现的这些问题的.因为不能调试..能调试就好啦.谢谢!


那你能不能找到引发错误的那句话,把它贴出来看看
[/Quote]
现在就是不知道哪里引发这个错误的.知道就不用贴出来啦.谢谢!
lunat 2009-01-08
  • 打赏
  • 举报
回复
看了一下 你这个错误是在窗口关闭的时候发生的
窗口关闭的时候,DataGridView关闭或者析构的时候发生错误,具体类型是参数错误
你看一下有没有InternalException

估计是你的DataGridView有问题,比如在还没有完全打开的时候就关闭....或者正在进行某些操作啊,后者某些东西没有初始化完成...等等 都有可能
HDNGO 2009-01-08
  • 打赏
  • 举报
回复
索引超出了?
acns 2009-01-08
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 tonyepaper 的回复:]
但上面的这些方法我都没调用.而且没出现我自己的类,所以不知道问题出在哪,应该怎么改.大家都是怎么处理客户端出现的这些问题的.因为不能调试..能调试就好啦.谢谢!
[/Quote]

那你能不能找到引发错误的那句话,把它贴出来看看
zt_100094 2009-01-08
  • 打赏
  • 举报
回复
ArgumentOutOfRangeException

columnIndex is less than -1 or greater than the number of columns in the control minus 1.
-or-
rowIndex is less than -1 or greater than the number of rows in the control minus 1.

分析一下,代码里调用的行或者列越界了
hongqi162 2009-01-08
  • 打赏
  • 举报
回复
越界访问
TonyWu66 2009-01-08
  • 打赏
  • 举报
回复
但上面的这些方法我都没调用.而且没出现我自己的类,所以不知道问题出在哪,应该怎么改.大家都是怎么处理客户端出现的这些问题的.因为不能调试..能调试就好啦.谢谢!
xfreyes 2009-01-08
  • 打赏
  • 举报
回复
差不多了
acns 2009-01-08
  • 打赏
  • 举报
回复
ArgumentOutOfRangeException

columnIndex is less than -1 or greater than the number of columns in the control minus 1.
-or-
rowIndex is less than -1 or greater than the number of rows in the control minus 1.

分析一下,代码里调用的行或者列越界了
greystar 2009-01-08
  • 打赏
  • 举报
回复
你要记录是运行了哪行代码哪个方法,接受的变量是什么.等出错的信息.exception会提供给你的.
Dobzhansky 2009-01-08
  • 打赏
  • 举报
回复
那个帖子的代码我简化了一下:
多次点击, 行来回切换, 就报那个错误, 错误堆栈跟你的, 那个帖子的完全一样
分析一下这段看, 窗体放置 DataGridView 默认属性


public partial class Form1 : Form
{
DataTable dt = null;
public Form1()
{
InitializeComponent();
}

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
CreateTable();
dataGridView1.DataSource = dt;
dataGridView1.CellLeave+=new DataGridViewCellEventHandler(dataGridView1_CellLeave);
}

void CreateTable()
{
dt = new DataTable();
dt.Columns.Add("a");
dt.Columns.Add("b");
dt.Columns.Add("c");
dt.Columns.Add("d");
}

void dataGridView1_CellLeave(object sender, DataGridViewCellEventArgs e)
{
if (this.dataGridView1.Columns[e.ColumnIndex].Name.ToUpper() == "b".ToUpper())
{
dataGridView1[e.ColumnIndex, e.RowIndex].Value += "c";
}
}
TonyWu66 2009-01-08
  • 打赏
  • 举报
回复
[Quote=引用 18 楼 lovehongyun 的回复:]
错误信息:指定的参数已超出有效值的范围。
参数名: rowIndex
类名:DataGridView
方法名:GetCellDisplayRectangle

写的很清楚.
[/Quote]
但类名是DataGridView 我不可能去改它的代码吧.我的意思是如何找出真正产生此问题的原因然后解决这个问题.谢谢!
lovehongyun 2009-01-08
  • 打赏
  • 举报
回复
错误信息:指定的参数已超出有效值的范围。
参数名: rowIndex
类名:DataGridView
方法名:GetCellDisplayRectangle


写的很清楚.
TonyWu66 2009-01-08
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 whmjw 的回复:]
具体的你要生成 的可执行文件时不要用Release模式 要用Debug模式,这样在生成 Exe文件时会生成相应的PDB文件,这样如果你的程序报错的话,会在Exception里会显示引起报错的具体哪个文件名与在这个文件里具体哪一行数这样你就可以找到原因了,不过你还得需要Try{}Catch{}里去写日志,其他 的还是没有什么好的方法了,呵
[/Quote]
那如何利用PDB文件呢.没听懂.谢谢!
Dobzhansky 2009-01-08
  • 打赏
  • 举报
回复
怀疑 DataGridView 内部有个状态维护出了问题,,

Dobzhansky 2009-01-08
  • 打赏
  • 举报
回复
这个错误是微软的bug

参看:
http://social.msdn.microsoft.com/forums/en-US/winformsdatacontrols/thread/ec08d0b4-5779-49b3-ae8a-40d064e79374/

加载更多回复(3)

111,130

社区成员

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

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

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