Chr*_*ris 5 c# .net-4.0 invalidoperationexception winforms
我的 Winform 应用程序正在根AppDomain.CurrentDomain.UnhandledException级别记录和 Application.ThreadException ,我得到了这个异常:
System.InvalidOperationException:由于对象的当前状态,操作无效。在 System.Windows.Forms.DataGridView.DataGridViewDataConnection.ProcessListChanged(ListChangedEventArgs e) 在 System.Windows.Forms.DataGridView.DataGridViewDataConnection.currencyManager_ListChanged(对象发送者,ListChangedEventArgs e) 在 System.Windows.Forms.CurrencyManager.OnListChanged(ListChangedEventArgs e) 在System.Windows.Forms.CurrencyManager.List_ListChanged(对象发送者,ListChangedEventArgs e)在System.ComponentModel.BindingList
1.OnListChanged(ListChangedEventArgs e) at System.ComponentModel.BindingList1.FireListChanged(ListChangedType类型,Int32索引)在System.ComponentModel.BindingList1.InsertItem(Int32 index, T item) at System.Collections.ObjectModel.Collection1.Add(T项)在System.ComponentModel。 BindingList1.AddNewCore() at System.ComponentModel.BindingList1.System.ComponentModel.IBindingList.AddNew() 在 System.Windows.Forms.CurrencyManager.AddNew() 在 System.Windows.Forms.DataGridView.DataGridViewDataConnection.AddNew() 在 System.Windows.Forms.DataGridView.DataGridViewDataConnection.OnNewRowNeeded ()在System.Windows.Forms.DataGridView.OnRowEnter(DataGridViewCell&dataGridViewCell,Int32 columnIndex,Int32 rowIndex,布尔canCreateNewRow,布尔validationFailureOccurred)在System.Windows.Forms.DataGridView.SetCurrentCellAddressCore(Int32 columnIndex,Int32 rowIndex,布尔setAnchorCellAddress,布尔validateCurrentCell ,布尔通过MouseClick)在System.Windows.Forms.DataGridView.ProcessDownKeyInternal(键keyData,布尔&移动)在System.Windows.Forms.DataGridView.ProcessEnterKey(键keyData)在System.Windows.Forms.DataGridView.ProcessDialogKey(键keyData)在System.Windows.Forms.Control.ProcessDialogKey(Keys keyData) 在 System.Windows.Forms.TextBoxBase.ProcessDialogKey(Keys keyData) 在 System.Windows.Forms.Control.PreProcessMessage(Message& msg) 在 System.Windows.Forms.Control。 PreProcessControlMessageInternal(控制目标,消息&msg)在System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG&msg)
这是 ex.ToString() 的结果,它不返回我的应用程序的自定义代码,仅返回内部 System.Windows.Forms 方法。
在某些客户机器上有时会出现异常,我什至无法自己重现它。
这味道不好,我的假设是当我更改 datagridview 的数据源边界时。但在这种情况下,我至少应该在异常堆栈中看到我的类,但这里什么也没有。
有什么线索可以找到根本原因或进行调试吗?
非常感谢
如果您调查堆栈跟踪,您将看到问题的根源:客户尝试在网格上添加新记录,因此事件处理程序尝试将记录添加到数据源,这会导致另一个事件处理程序,尝试将记录添加到绑定列表,这会导致事件currencyManager_listChanged触发,但由于对象状态错误而失败。
您要么处置列表,要么不取消订阅已处置控件的事件。
| 归档时间: |
|
| 查看次数: |
1811 次 |
| 最近记录: |