dotnet / dotnet/winforms

Clipboard.ContainsText behaves differently in .NET8 .NET9 .NET10

Open
#14,172 8 comments 0 reactions 0 assignees View on GitHub
area-Clipboard waiting-on-team
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
1d 13m
Merged PRs (30d)
85

Description

### .NET version

net8.0-windows
net9.0-windows
net10.0-windows

### Did it work in .NET Framework?

Yes

### Did it work in any of the earlier releases of .NET Core or .NET 5+?

net8.0-windows

### Issue description

The following code displays "Nothing" in .net9. Both .net8 and .net10 display "Something"
```C#
DataObject data = new DataObject();
data.SetData("Something");
Clipboard.SetDataObject(data);

if(Clipboard.ContainsText())
MessageBox.Show(this, Clipboard.GetText());
else
MessageBox.Show(this, "Nothing");
```

### .net8

![Image](https://github.com/user-attachments/assets/bf24c653-1ed8-4ca7-b8f5-1032c538a7b4)

### .net9

![Image](https://github.com/user-attachments/assets/77256a3c-931b-4e48-be46-7b08ed85c7d9)

### .net10

![Image](https://github.com/user-attachments/assets/96ef1ac8-14e9-43b8-9e58-f839570704bb)

### Steps to reproduce

[WinFormsApp2.zip](https://github.com/user-attachments/files/24346385/WinFormsApp2.zip)
You may use this project as a reference

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.