Repository navigation
Closed
Milestone
Description
.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);
}
}
Metadata
Metadata
Assignees
Labels
No labels
Activity
Olina-Zhang commentedon Jul 13, 2026
Also reproduce this issue in .NET framework 4.8.1 app when enabling tooltip quirk in application's app.config file:
KlausLoeffelmann commentedon Jul 14, 2026
@LeafShi1, this is a migration blocker from earlier NetFx version, FWIW.
I think this is more than Prio 2.
Zheng-Li01 commentedon Jul 16, 2026
Verified the issue with .NET 11.0.100-preview7.26365.114 build, the issue has been fixed that no exception pops as below screenshot.
VerifyIssue.mp4
Amy-Li03 commentedon Aug 3, 2026
Verified on .NET 11 Preview 7 test pass build: .NET 11.0.100-preview.7.26381.103, issue was fixed, test result is same as above.
GrahamClarkeQld commentedon Aug 31, 2026
I have upgraded .Net to 11.0.0-preview.7.26381.103 but I still get this error in a C# WinForms app that isn't actually using a ToolTip:
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
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, MessageId msg, WPARAM wparam, LPARAM lparam)
I would appreciate being pointed to a resource that will show me how to perform a dump when the exception occurs.
Olina-Zhang commentedon Aug 31, 2026
@GrahamClarkeQld Can you please provide your Winforms app with that same exception occurred? We can test and investigate further. Thanks.
GrahamClarkeQld commentedon Aug 31, 2026
Silly me. My release exe file is now in a new folder under ...\bin\Release\net11.0-windows10.0.26100
Please ignore my post