简体   繁体   中英

.NET Framework 4.6.1 error with System.Windows.Forms

I had a project running without any problems on .NET Framework 4.5 but today I updated to 4.6.1 version and it crashes at the very beginning of the execution.

The message displayed is shown above:

See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: index at System.Windows.Forms.TreeNodeCollection.get_Item(Int32 index) at System.Windows.Forms.DataGridView.OnCurrentCellChanged(EventArgs e)
at 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(Boolean 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)

In my App.config file I have this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
  </startup>
</configuration>

Does anyone know what can be causing the problem? Is it related to the System.Windows.Forms and the .NET Framework 4.6.1 update?

Thanks in advance.

Finally I managed to solve it. The issue was that .NET Framework 4.6.1 has optimized something that made some parts of my code to run faster, so I had a collision with two events (one was supposed to run before the other and with .NET 4.6.1 was happening the opposite). That's why running it in .NET Framework 4.5 was working properly, the two events were launched in the correct order.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM