System.Windows.Forms出现.NET Framework 4.6.1错误

时间:2016-03-02 16:21:46

标签: c# .net .net-framework-version

我有一个项目在.NET Framework 4.5上运行没有任何问题,但今天我更新到4.6.1版本,它在执行的最初阶段崩溃。

显示的信息如上所示:

  

有关调用实时的详细信息,请参阅此消息的结尾   (JIT)调试而不是此对话框。

     

**************例外文字**************

     

System.ArgumentOutOfRangeException:指定的参数不在   有效值范围。参数名称:索引位于   System.Windows.Forms.TreeNodeCollection.get_Item(Int32 index)at   System.Windows.Forms.DataGridView.OnCurrentCellChanged(EventArgs e)
  在System.Windows.Forms.DataGridView.SetCurrentCellAddressCore(Int32   columnIndex,Int32 rowIndex,Boolean setAnchorCellAddress,Boolean   validateCurrentCell,Boolean throughMouseClick)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.MakeFirstDisplayedCellCurrentCell(布尔   includeNewRow)at   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)

在我的App.config文件中,我有这个:

<?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更新有关吗?

提前致谢。

1 个答案:

答案 0 :(得分:1)

最后我设法解决了这个问题。问题是.NET Framework 4.6.1优化了使我的代码的某些部分运行得更快的东西,所以我遇到了两个事件的冲突(一个应该在另一个之前运行并且.NET 4.6.1正在发生相反)。这就是为什么在.NET Framework 4.5中运行它正常工作,这两个事件以正确的顺序启动。

相关问题