Requested Clipboard operation did not succeed
keithyipkw opened this issue · 5 comments
Windows clipboard API is unreliable. Failures are frequent. It is better to cancel the copy when any errors occur instead of quitting. At least it allows users to copy texts by selection and save their typed messages.
Steps:
- Show an ExceptionReporter
- Copy some texts in ExceptionReport, Visual Studio, Excel and etc
- Click the "Copy Detail" or "Copy" button in ExceptionReporter
- Repeat 2 and 3 until a popup "Requested Clipboard operation did not succeed"
- ExceptionReport disappear
Try inplementing SharpClipboard for this.
Thanks @keithyipkw I should like to fix this
I don't think I've experienced it, but I believe it
Clipboard
mutation methods should be enclosed by try-catches. According to MS doc, SetDataObject
may throw ExternalException
. A StackOverflow question also discussed the problem.
Sorry I didn't get around to this earlier.
I read the StackOverflow question and one of the main solutions is to basically call Clipboard.Clear()
before SetDataObject()
.
There are some other variations on that, like checking if the clipboard is being used by another app, but which seem like a lot more effort.
I did add some code today to at catch any exceptions during the clipboard operation and set the status/error text accordingly.
Since nothing seems to really fix this (even retrying/clearing the clipboard just makes it happen less often) - just handling the exception is the main fix here.