SharpClipboard icon indicating copy to clipboard operation
SharpClipboard copied to clipboard

It won't be able to listen to the clipboard data after running for a long time

Open shushu789 opened this issue 2 years ago • 9 comments

I'm not sure why, I'm using it in .NET 7 WPF, but sometimes it somehow doesn't work after more than an hour or two of runtime, many users have reported this problem because my WPF application is installed on many user devices, I have no other more options, I just use "clipboard. ClipboardChanged += ClipboardChanged;" like this:

InitializeComponent(). clipboard.ClipboardChanged += ClipboardChanged. ... if (e.ContentType == SharpClipboard.ContentTypes.Text) { string clipboardText = clipboard. log.Debug("clipboardText:" + clipboardText). }

It happens regularly, but not regularly, sometimes it is normal for several days, sometimes it may happen every day in a row, and when it happens, I don't get debug data in the user's logs. I would like to know where this problem may occur? Or is there any other way to debug or some possible options to solve this problem? Thanks

Development Environment

  • windows 10 20H2
  • visual studio 17.5.0
  • net 7
  • SharpClipboard 3.5.2

shushu789 avatar Apr 29 '23 15:04 shushu789

Any progress? It also happened in my plugin, also WPF and .NET 7

After working for a long time, it seems the clipboard listener will stop and app can't record copy actions.

rainyl avatar Jul 25 '23 15:07 rainyl

I just suddenly find that after I close GIMP (v2.10.34), the SharpClipboard will stop listening the changes of clipboard, I tried to debug it, but it seems that WndProc function stops receiving messages like WM_DRAWCLIPBOARD after GIMP closed, I am not familiar with this project so I don't know why. Other clipboard tools like windows builtin clipboard viewer (shortcut: Win+V) worked normally.

https://github.com/Willy-Kimura/SharpClipboard/blob/6584fccb08de7d039074cba4c96dd3f59630e5b6/SharpClipboard/Views/ClipboardHandle.cs#L145

Maybe this can help you to reproduce this problem.

BTW, I debugged it using the two test project in this repo.

rainyl avatar Aug 16 '23 14:08 rainyl

UPDATE:

  • newly created winform and wpf apps will also be influenced
  • replacing SetClipboardViewer() with AddClipboardFormatListener() solved this problem

rainyl avatar Aug 18 '23 13:08 rainyl

@rainyl I have given up on using this project, and I noticed that the project has not been updated in a long time, and has not responded to these questions. I think the author has stopped maintaining the project, so I have given up

shushu789 avatar Aug 18 '23 13:08 shushu789

@shushu789 ☹️ , I have noticed that too, do you know better alternative libraries ?

rainyl avatar Aug 18 '23 14:08 rainyl

@rainyl Sorry, I don't know, I'm using the traditional solution now, no third-party libraries are used

shushu789 avatar Aug 18 '23 14:08 shushu789

@shushu789 Well, Thanks~

rainyl avatar Aug 18 '23 14:08 rainyl

Hello @shushu789 @rainyl

I'll be updating the library with a fix to this issue and some few more updates. Will let you know once the update is ready. Nope, it's not dead yet.

Willy-Kimura avatar Sep 07 '23 20:09 Willy-Kimura

Great, Thanks for your works 😄

rainyl avatar Sep 08 '23 09:09 rainyl