Failed to Clipboard.GetData() as the specified format
See original GitHub issue.NET version
.NET 8.0.100-preview.5.23274.2
Did it work in .NET Framework?
Yes
Did it work in any of the earlier releases of .NET Core or .NET 5+?
Yes, it works in .NET 6.0/7.0/8.0.100-preview5.23253.20. Maybe caused by: https://github.com/dotnet/winforms/pull/9088
Issue description
Testapp: Testapp.zip
.NET 8.0
.NET 7.0
Steps to reproduce
- Create a WinForms .NET Core project.
- Add a button control to form designer, double click button1 and type below code in function button1_Click.
Color c = System.Drawing.Color.Black;
string format = "testabc";
Clipboard.Clear();
Clipboard.SetData(format, c);
Clipboard.ContainsData(format);
object ob = null;
ob = Clipboard.GetData(format);
- Add a breakpoint at the end of the event, build and run the application, click button1.
- Observe the value of ob.
Issue Analytics
- State:
- Created 4 months ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Clipboard format is not valid - Visual Basic
The specified Clipboard format is incompatible with the method being executed. Among the possible causes for this error are:.
Read more >Clipboard fail to restore data with setdataobject
GetDataObject().GetDataPresent(DataFormats.Text)) //if the clipboard has text then we do something with it to get that info in the blabla here { ...
Read more >Clipboard API and events
The event fires before any clipboard data is inserted into the document. If the cursor is in an editable context, the paste action...
Read more >DataTransfer: getData() method - Web APIs - MDN Web Docs
The DataTransfer.getData() method retrieves drag data (as a string) for the specified type. If the drag operation does not include data, ...
Read more >Clipboard (Copy & Paste)
getData ('text/plain'): Returns the data that has been read from the clipboard by the paste operation in the specified format. document.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@Philip-Wang01 we don’t need it open, I’m going to close it. Thanks for the heads up.
After investigation, the test cases failed for similar reasons as 9322. This test case is a “console application”, not a “winforms application”. It can be fixed when
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>is added in the project file. But the status of this issue is still work in progress, @JeremyKuhne do we still need to keep the issue open?