开发者

Exception handling help

I have written and tested a WinForms application and everything works fine on my machine (cliche, I know). When I created a setup project and installed it on a co-worker's machine, he receives the following message:

   **开发者_运维百科************ Exception Text **************
   System.IndexOutOfRangeException: There is no row at position 0.
   at System.Data.RBTree`1.GetNodeByIndex(Int32 userIndex)
   at System.Data.RBTree`1.get_Item(Int32 index)
   at System.Data.DataRowCollection.get_Item(Int32 index)
   at MyApp.MainForm.MainForm_Load(Object sender, EventArgs e)
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

I will admit I am a beginner when it comes to handling exceptions like this one. The text doesn't make a whole lot of sense to me and I'm unsure of the best way to debug this since I can't get the error to occur on my machine.

Can anyone tell what the problem is, or advise me on the best way to debug this? Any help is greatly appreciated!


Apparently you are using a DataRowCollection object on your main form load event handler, and this DataRowCollection object is empty (i.e. contains no rows). The form load event handler seems to assume that it will not be empty.

I suggest you set a breakpoint (F9) on the opening brace of MainForm_Load and step (F10 or F11) through your code until you find where the code tries to use the DataRowCollection.


Visual Studio has a remote debugging feature that is very nice. If you start the remote debugging host on the coworker's computer, then you can attach to that running process from within the IDE on your own machine. I have used this a couple of time with very good results.

http://msdn.microsoft.com/en-us/library/y7f5zaaa(VS.71).aspx


Sounds like a difference in the data - you're trying to access a node in a tree by index that doesn't exist...


You're creating a data row collection and accesing it with collection[0] without validating if it has at least one element to start with. Perhaps your coleague connects to an empty data store that has no rows?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜