【发布时间】:2017-06-04 07:37:12
【问题描述】:
我的 Winform 应用在根级别记录 AppDomain.CurrentDomain.UnhandledException 和 Application.ThreadException,我得到了这个异常:
System.InvalidOperationException:由于对象的当前状态,操作无效。在 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.List_ListChanged(Object sender, ListChangedEventArgs e) at System.ComponentModel.BindingList
1.OnListChanged(ListChangedEventArgs e) at System.ComponentModel.BindingList1.FireListChanged(ListChangedType type, Int32 index) at System.ComponentModel.BindingList1.InsertItem(Int32 index, T item) at System.Collections.ObjectModel.Collection1.Add(T item ) 在 System.ComponentModel.BindingList1.AddNewCore() at System.ComponentModel.BindingList1.System.ComponentModel.IBindingList.AddNew() 在 System.Windows.Forms.CurrencyManager.AddNew() 在 System.Windows.Forms.DataGridView.DataGridViewDataConnection.AddNew() 在系统。 Windows.Forms.DataGridView.DataGridViewDataConnection.OnNewRowNeeded() 在 System.Windows.Forms.DataGridView.OnRowEnter(DataGridViewCell& dataGridViewCell, Int32 columnIndex, Int32 rowIndex, Boolean canC reateNewRow, Boolean validationFailureOccurred) at System.Windows.Forms.DataGridView.SetCurrentCellAddressCore(Int32 columnIndex, Int32 rowIndex, Boolean setAnchorCellAddress, Boolean validateCurrentCell, Boolean throughMouseClick) 在 System.Windows.Forms.DataGridView.ProcessDownKeyInternal(Keys keyData, Boolean&moved) 在 System .Windows.Forms.DataGridView.ProcessEnterKey(Keys keyData) 在 System.Windows.Forms.DataGridView.ProcessDialogKey(Keys keyData) 在 System.Windows.Forms.Control.ProcessDialogKey(Keys keyData) 在 System.Windows.Forms.TextBoxBase.ProcessDialogKey (键 keyData)在 System.Windows.Forms.Control.PreProcessMessage(Message& msg) 在 System.Windows.Forms.Control.PreProcessControlMessageInternal(Control target, Message& msg) 在 System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg )
这是 ex.ToString() 的结果,它不返回我的应用程序的自定义代码,只返回内部 System.Windows.Forms 方法。
在某些客户机器上不时引发异常,我什至无法自己重现它。
这味道不好,我的假设是当我更改 datagridview 的数据源边界时。但在这种情况下,我至少应该在异常堆栈中看到我的类,但这里什么也没有。
有任何线索可以找到根本原因或进行调试吗?
非常感谢
【问题讨论】:
-
当然,它并不完全指向您的代码,但它确实指向
System.Windows.Forms.DataGridView,从中可以引导您朝着您的DataGridView必须包含一些无效数据的方向前进。 -
何时引发异常?您必须从客户那里获得一些信息。但是,我很确定这是相关的并且可能会有所帮助:stackoverflow.com/questions/2359124/…
-
是的,它与我的 datagridview 数据有关,但很难找到,因为我的代码中没有显示异常...我已经在更新过程中添加了一个 try/catch all 但它什么也没捕获。 .
-
@Chris:是什么(操作)导致了这个异常?用户是否修改了 DataGridView 中的某些内容,例如单击了最后一行?
-
好吧,因为我稍后正在查看日志,每次我问他们时,他们都无法描述这些操作......我正在考虑为客户添加一个对话框从他那里收集手动输入!而且我不明白为什么代码没有列在堆栈中,这对我来说是个谜
标签: c# winforms .net-4.0 invalidoperationexception