dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.42k stars 984 forks source link

Exception pops up when executing ImageList.ImageCollection.SetKeyName(Int32 index, String name) #9174

Closed MelonWang1 closed 1 year ago

MelonWang1 commented 1 year ago

.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

  1. Create a .NET Core 8.0 application with ImageList Control
  2. Open ImageList smart tag and click "Choose images"
  3. Add some image
  4. Build and run

Screenshot 2023-05-25 022221

https://github.com/dotnet/winforms/assets/94418985/e1c78781-3033-4730-a5c9-404917ec26f7

Tanya-Solyanik commented 1 year ago

Duplicate of https://github.com/microsoft/winforms-designer/issues/5233