.NET Framework 4.6.1 error with System.Windows.Forms
本文关键字:with System Windows Forms error Framework NET | 更新日期: 2023-09-27 18:37:01
我有一个项目运行.NET Framework 4.5
没有任何问题,但今天我更新到 4.6.1 版本,它在执行开始时崩溃了。
显示的消息如上所示:
有关调用实时的详细信息,请参阅此消息的末尾 (JIT) 调试,而不是此对话框。
异常文本
******System.ArgumentOutOfRangeException:指定的参数不在 有效值的范围。参数名称:索引位于 System.Windows.Forms.TreeNodeCollection.get_Item(Int32 索引) at System.Windows.Forms.DataGridView.OnCurrentCellChanged(EventArgs e)
at System.Windows.Forms.DataGridView.SetCurrentCellAddressCore(Int32 columnIndex, Int32 rowIndex, Boolean setAnchorCellAddress, Boolean validateCurrentCell, Boolean through MouseClick) at System.Windows.Forms.DataGridView.SetAndSelectCurrentCellAddress(Int32 columnIndex, Int32 rowIndex, Boolean setAnchorCellAddress, Boolean validateCurrentCell, Boolean throughMouseClick, Boolean clearSelection, Boolean forceCurrentCellSelection) at System.Windows.Forms.DataGridView.MakeFirstDisplayCellCurrentCell(Boolean 包括新行)在 System.Windows.Forms.DataGridView.OnHandleCreated(EventArgs e) at System.Windows.Forms.Control.WmCreate(Message&m) at System.Windows.Forms.Control.WndProc(Message&m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在我的应用程序配置文件中,我有这个:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
</configuration>
有谁知道是什么导致了问题?是否与System.Windows.Forms
和.NET Framework 4.6.1
更新有关?
提前谢谢。
最后我设法解决了它。问题是 .NET Framework 4.6.1 优化了一些东西,使我的代码的某些部分运行得更快,所以我与两个事件发生了冲突(一个应该在另一个之前运行,而 .NET 4.6.1 则相反)。这就是为什么在.NET Framework 4.5中运行它正常工作的原因,这两个事件以正确的顺序启动。