Skip to content

Regression: Clipboard.GetText() returns empty string or corrupted text (mojibake) randomly in .NET 10 #11402

@rampaa

Description

@rampaa

Description

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.

Example of corrupted output:

Expected:
「うわ、ほんとだ……あれ、どれくらいの高さなんだろ」
Actual:
????????・????????????????
or:
"" (Length = 0)

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

  1. Create a WPF application targeting .NET 10.
  2. Monitor clipboard changes using WM_CLIPBOARDUPDATE.
  3. On clipboard updates, call Clipboard.GetText() to retrieve text contents.
  4. 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:

  1. An empty string (Length == 0)
  2. 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.

Known Workarounds

No response

Impact

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions