question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 image

.NET 7.0 image

Steps to reproduce

  1. Create a WinForms .NET Core project.
  2. 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);
  1. Add a breakpoint at the end of the event, build and run the application, click button1.
  2. Observe the value of ob.

Issue Analytics

  • State:closed
  • Created 4 months ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
JeremyKuhnecommented, Jun 29, 2023

@Philip-Wang01 we don’t need it open, I’m going to close it. Thanks for the heads up.

0reactions
Philip-Wang01commented, Jun 29, 2023

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found