PandaWood / ExceptionReporter.NET

ExceptionReporter is a .NET component that gathers detailed information on an Exception and the application/system running it. It allows the user to copy, save or send a custom-formatted report to the developer
MIT License
51 stars 32 forks source link

Requested Clipboard operation did not succeed #41

Closed keithyipkw closed 3 years ago

keithyipkw commented 5 years ago

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:

  1. Show an ExceptionReporter
  2. Copy some texts in ExceptionReport, Visual Studio, Excel and etc
  3. Click the "Copy Detail" or "Copy" button in ExceptionReporter
  4. Repeat 2 and 3 until a popup "Requested Clipboard operation did not succeed"
  5. ExceptionReport disappear
Willy-Kimura commented 5 years ago

Try inplementing SharpClipboard for this.

PandaWood commented 4 years ago

Thanks @keithyipkw I should like to fix this I don't think I've experienced it, but I believe it

keithyipkw commented 4 years ago

Clipboard mutation methods should be enclosed by try-catches. According to MS doc, SetDataObject may throw ExternalException. A StackOverflow question also discussed the problem.

PandaWood commented 3 years ago

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.

PandaWood commented 3 years ago

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.