.NET version
.NET 10.0.9
Did it work in .NET Framework?
Yes
Did it work in any of the earlier releases of .NET Core or .NET 5+?
Tested in .NET 5 and it also threw the same exception
Issue description
Since migrating a .NET Framework WinForms solution to .NET 10 I've been getting KeyNotFoundException's occurring/being thrown - seemingly by Framework code. I've added a minimal reproducible example
System.Collections.Generic.KeyNotFoundException
Message=The given key was not present in the dictionary.
StackTrace:
at System.Windows.Forms.KeyboardToolTipStateMachine.Transition(IKeyboardToolTip tool, ToolTip tooltip, SmEvent event)
at System.Windows.Forms.KeyboardToolTipStateMachine.Transit(SmEvent event, IKeyboardToolTip source)
at System.Windows.Forms.NativeWindow.Callback(HWND hWnd, UInt32 msg, WPARAM wparam, LPARAM lparam)
at Windows.Win32.PInvoke.DispatchMessage(MSG* lpMsg)
at System.Windows.Forms.Application.LightThreadContext.FPushMessageLoop(msoloop uReason)
at System.Windows.Forms.Application.LightThreadContext.RunMessageLoop(msoloop reason, Boolean fullModal)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(msoloop reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Program.Main() in ...\Program.cs:line 12
Steps to reproduce
using System;
using System.Drawing;
using System.Windows.Forms;
internal static class Program
{
[STAThread]
private static void Main()
{
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
Application.ThreadException += (_, e) => MessageBox.Show(e.Exception.ToString(), "Reproduced");
Application.Run(new ReproForm());
}
}
internal sealed class ReproForm : Form
{
private readonly TextBox _first = new TextBox() { Text = "First", Left = 20, Top = 30, Width = 200, TabIndex = 0 };
private readonly TextBox _second = new TextBox() { Text = "Second", Left = 250, Top = 30, Width = 200, TabIndex = 1 };
private readonly ToolTip _toolTip = new ToolTip()
{
InitialDelay = 50,
ReshowDelay = 25,
AutoPopDelay = 100,
ShowAlways = true
};
private bool _redirected;
public ReproForm()
{
Text = "Hold Tab for one second";
ClientSize = new Size(470, 90);
Controls.AddRange(new[] { _first, _second });
_toolTip.SetToolTip(_first, "First tooltip");
_toolTip.SetToolTip(_second, "Second tooltip");
_toolTip.Popup += (_, __) =>
{
if (_redirected || !_second.Focused)
return;
_redirected = true;
_first.Focus();
};
Shown += (_, __) => _first.Focus();
}
protected override void Dispose(bool disposing)
{
if (disposing)
_toolTip.Dispose();
base.Dispose(disposing);
}
}
.NET version
.NET 10.0.9
Did it work in .NET Framework?
Yes
Did it work in any of the earlier releases of .NET Core or .NET 5+?
Tested in .NET 5 and it also threw the same exception
Issue description
Since migrating a .NET Framework WinForms solution to .NET 10 I've been getting
KeyNotFoundException's occurring/being thrown - seemingly by Framework code. I've added a minimal reproducible exampleSteps to reproduce