System.IndexOutOfRangeException
HResult=0x80131508
Message=Index was outside the bounds of the array.
Source=System.Windows.Forms
StackTrace:
at System.Windows.Forms.ImageList.ImageCollection.SetKeyName(Int32 index, String name)
at WinFormsApp6.Form1.InitializeComponent() in C:\Users\xxx\source\repos\WinFormsApp6\WinFormsApp6\Form1.Designer.cs:line 40
at WinFormsApp6.Form1..ctor() in C:\Users\xxx\source\repos\WinFormsApp6\WinFormsApp6\Form1.cs:line 7
at WinFormsApp6.Program.Main() in C:\Users\xxx\source\repos\WinFormsApp6\WinFormsApp6\Program.cs:line 14
Steps to reproduce
Create a .NET Core 8.0 application with ImageList Control
Open ImageList smart tag and click "Choose images"
.NET version
.NET 8.0.100-preview.5.23274.2
Did it work in .NET Framework?
Yes
Did it work in any of the earlier releases of .NET Core or .NET 5+?
Yes, it doesn't reproduced in .Net 7.0.
Issue description
Exception pops up when executing ImageList.ImageCollection.SetKeyName(Int32 index, String name), it may be caused by PR: https://github.com/dotnet/winforms/pull/9073
Failed log:
System.IndexOutOfRangeException HResult=0x80131508 Message=Index was outside the bounds of the array. Source=System.Windows.Forms StackTrace: at System.Windows.Forms.ImageList.ImageCollection.SetKeyName(Int32 index, String name) at WinFormsApp6.Form1.InitializeComponent() in C:\Users\xxx\source\repos\WinFormsApp6\WinFormsApp6\Form1.Designer.cs:line 40 at WinFormsApp6.Form1..ctor() in C:\Users\xxx\source\repos\WinFormsApp6\WinFormsApp6\Form1.cs:line 7 at WinFormsApp6.Program.Main() in C:\Users\xxx\source\repos\WinFormsApp6\WinFormsApp6\Program.cs:line 14
Steps to reproduce
https://github.com/dotnet/winforms/assets/94418985/e1c78781-3033-4730-a5c9-404917ec26f7