You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Regression: Clipboard.GetText() returns empty string or corrupted text (mojibake) randomly in .NET 10 #14322
After migrating an application to .NET 10, Clipboard.GetText() sometimes returns corrupted text or an empty string when reading Unicode (e.g., Japanese) content from the Windows clipboard. This behavior did not occur prior to .NET 10.
The issue appears intermittently and is difficult to reproduce deterministically, but becomes noticeable under frequent clipboard updates. Note that using Clipboard.ContainsText(TextDataFormat.UnicodeText) and Clipboard.GetText(TextDataFormat.UnicodeText) has the exact same problem.
Reproduction Steps
Create a WPF application targeting .NET 10.
Monitor clipboard changes using WM_CLIPBOARDUPDATE.
On clipboard updates, call Clipboard.GetText() to retrieve text contents.
Frequently copy Unicode text to Clipboard
Minimal example:
if (Clipboard.ContainsText()) // You can also use Clipboard.ContainsText(TextDataFormat.UnicodeText)
{
// Occasionally returns empty string or mojibake
string text = Clipboard.GetText(); // Clipboard.GetText(TextDataFormat.UnicodeText)
}
Intermittently, the returned string is either empty (this is more common) or contains corrupted characters instead of the original Unicode text (this is rarer).
Expected behavior
Expected behavior
Clipboard.GetText() should consistently return the correct Unicode text as placed on the clipboard, or throw a managed exception if the clipboard data is temporarily unavailable.
It should never silently return corrupted text or an empty string when valid Unicode text exists.
Actual behavior
Clipboard.GetText() intermittently returns:
An empty string (Length == 0)
Or a string containing mojibake (e.g., ?, ・), or
No exception is thrown in these cases.
Regression?
Yes.
Yes. This code path worked reliably in previous .NET versions. I never had a problem with .NET 5, .NET 6, .NET 7, .NET 8, .NET 9.
I'm pretty sure I know what is causing this. We weren't properly checking the result of GetData after QueryHasData. Working with the WinForms team to try and get this serviced.
Thanks @Shyam-Gupta! Does this issue need to be tagged as 💥 regression-release, since the issue did not occur in .NET 9? FWIW this issue is a hard blocker on .NET 10 migration for me.
Any chance this issue could be tagged with 💥 regression-release as it is a .NET 10 regression? I had to revert one of my projects to .NET 9 because of this bug, and .NET 9’s end-of-support date is November 10, 2026.
This issue seems that same as this issue #14308, which have been fixed in 10.0.6-10.0.202 build, could you please have a try to install the latest. NET 10.0 to see if this issue fixed?
I don't think It's the same issue as #14308. That issue was about users experiencing crashes, this one is about getting bad data from the Clipboard after updating to .NET 10.
Also @Shyam-Gupta said that the changes made in #14257 (which are not even fully back-ported to .NET 10 in #14296 AFAICT) does not address this issue according to their internal testings, see: #14257 (comment).
An opt-in AppContext switch would work well for me. Thank you, @Shyam-Gupta!
it still returns an empty string if the QueryGet* API fails
If this means that Clipboard.GetText() can still return an empty string when there is non-empty text in the Clipboard, I think it would be better for the Windows.Clipboard.ThrowExceptionsForGetAPIs switch to make these failures throw an exception as well. Otherwise, we still cannot reliably distinguish between the clipboard actually containing an empty string and a failure to retrieve the text.
This is the existing .NET 9 behavior with Clipboard.GetText() API as it internally calls QueryGetText() API which does not throw. The current changes won't change this behavior. In my rigorous stress testing, I found that with the new AppContext switch turned on, the GetText() will return empty string during < 0.5% of the instances and it is inline with the existing .NET 9 behavior.
Yes, I did read it's the existing behavior in .NET 9-. I was just saying that, especially after introducing a switch like Windows.Clipboard.ThrowExceptionsForGetAPIs, not returning an empty string for an error case and properly throwing would make Clipboard.GetText() much more consistent and reliable for people who opt into using the new switch. Not conflating a valid state with error state would be better IMHO, especially more so when there's a new switch for it where we specifically opt into getting exceptions for error states instead of getting empty strings.
Tested in the latest .NET 11 RC2 build: 11.0.100-rc.2.26458.109 + built private dls from the main branch of WinForms repo, it was fixed.
When Windows.Clipboard.ThrowExceptionsForGetAPIs is set to true, Clipboard Get* APIs throw exceptions when clipboard access failures occur.
When Windows.Clipboard.ThrowExceptionsForGetAPIs is set to false, Clipboard Get* APIs suppress clipboard-related exceptions and return an empty string.
Activity
rampaa commentedon Jan 29, 2026
Possibly caused by dotnet/wpf#10544
JeremyKuhne commentedon Jan 30, 2026
I'm pretty sure I know what is causing this. We weren't properly checking the result of
GetDataafterQueryHasData. Working with the WinForms team to try and get this serviced.JeremyKuhne commentedon Jan 30, 2026
I've put up a PR in WinForms main that @Shyam-Gupta is going to take further to vet that it fixes your issue and get it through our servicing process.
rampaa commentedon Feb 21, 2026
@merriemcgaw @Shyam-Gupta
Does this issue need to be transferred to the WinForms repo (like #14308) in order for it to be backported to .NET 10?
Shyam-Gupta commentedon Feb 23, 2026
@rampaa I have transferred the issue to WinForms repo. Thanks.
rampaa commentedon Apr 14, 2026
Thanks @Shyam-Gupta! Does this issue need to be tagged as
💥 regression-release, since the issue did not occur in .NET 9? FWIW this issue is a hard blocker on .NET 10 migration for me.SimonZhao888 commentedon Apr 23, 2026
A race read occurring while reading the clipboard content may be the cause of this issue.
rampaa commentedon May 29, 2026
Any chance this issue could be tagged with
💥 regression-releaseas it is a .NET 10 regression? I had to revert one of my projects to .NET 9 because of this bug, and .NET 9’s end-of-support date is November 10, 2026.Zheng-Li01 commentedon Jun 1, 2026
This issue seems that same as this issue #14308, which have been fixed in 10.0.6-10.0.202 build, could you please have a try to install the latest. NET 10.0 to see if this issue fixed?
rampaa commentedon Jun 1, 2026
I don't think It's the same issue as #14308. That issue was about users experiencing crashes, this one is about getting bad data from the Clipboard after updating to .NET 10.
Also @Shyam-Gupta said that the changes made in #14257 (which are not even fully back-ported to .NET 10 in #14296 AFAICT) does not address this issue according to their internal testings, see: #14257 (comment).
Shyam-Gupta commentedon Jun 2, 2026
@rampaa We have identified the root cause of this bug. I will create a PR soon. Thanks.
19 remaining items
rampaa commentedon Sep 2, 2026
An opt-in
AppContextswitch would work well for me. Thank you, @Shyam-Gupta!If this means that
Clipboard.GetText()can still return an empty string when there is non-empty text in the Clipboard, I think it would be better for theWindows.Clipboard.ThrowExceptionsForGetAPIsswitch to make these failures throw an exception as well. Otherwise, we still cannot reliably distinguish between the clipboard actually containing an empty string and a failure to retrieve the text.Shyam-Gupta commentedon Sep 2, 2026
This is the existing .NET 9 behavior with
Clipboard.GetText()API as it internally callsQueryGetText()API which does not throw. The current changes won't change this behavior. In my rigorous stress testing, I found that with the new AppContext switch turned on, theGetText()will return empty string during < 0.5% of the instances and it is inline with the existing .NET 9 behavior.rampaa commentedon Sep 2, 2026
Yes, I did read it's the existing behavior in .NET 9-. I was just saying that, especially after introducing a switch like
Windows.Clipboard.ThrowExceptionsForGetAPIs, not returning an empty string for an error case and properly throwing would makeClipboard.GetText()much more consistent and reliable for people who opt into using the new switch. Not conflating a valid state with error state would be better IMHO, especially more so when there's a new switch for it where we specifically opt into getting exceptions for error states instead of getting empty strings.Shyam-Gupta commentedon Sep 2, 2026
The unintended change in API behavior introduced in .NET 10 would be addressed by the new switch. However, we cannot change the existing API behavior.
AppContext switch for restoring exception handling behavior in WPF Cl…
AppContext switch for restoring exception handling behavior in WPF Cl…
AppContext switch for restoring exception handling behavior in WPF Cl…
[release/10.0] AppContext switch for restoring exception handling beh…
[release/11.0] AppContext switch for restoring exception handling beh…
Amy-Li03 commentedon Sep 10, 2026
Tested in the latest .NET 11 RC2 build: 11.0.100-rc.2.26458.109 + built private dls from the main branch of WinForms repo, it was fixed.
When
Windows.Clipboard.ThrowExceptionsForGetAPIsis set totrue, Clipboard Get* APIs throw exceptions when clipboard access failures occur.When
Windows.Clipboard.ThrowExceptionsForGetAPIsis set tofalse, Clipboard Get* APIs suppress clipboard-related exceptions and return an empty string.Olina-Zhang commentedon Sep 24, 2026
Verified with .NET 11 Oct 2026 Update Validation test pass build: .NET 11.0.0-RC.2.26473.101, issue has been fixed with above test result.