Outline
An unhandled exception occurs when the application attempts to access the clipboard, likely due to a race condition or the clipboard being locked by another process.
Reproduction Steps:
- Set PasteIntoFile to launch automatically on Windows startup.
- Restart the computer or log out and log back in.
- The exception dialog appears as soon as the desktop environment loads.
Error message
System.Runtime.InteropServices.ExternalException (0x800401D0): Requested Clipboard operation did not succeed.
at System.Windows.Forms.Clipboard.ThrowIfFailed(Int32 hr)
at System.Windows.Forms.Clipboard.GetDataObject(Int32 retryTimes, Int32 retryDelay)
at System.Windows.Forms.Clipboard.GetDataObject()
at WK.Libraries.SharpClipboardNS.Views.ClipboardHandle.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Environment:
- Application: PasteIntoFile v5.6.0.0
- OS: Windows 11 Pro 64-bit
- Runtime: .NET Framework 4.8
- Library involved: SharpClipboard v3.5.2.0
Loaded Assemblies (Summary):
- mscorlib (4.0.0.0)
- System.Windows.Forms (4.0.0.0)
- SharpClipboard (3.5.2.0)
- CommandLine (2.9.1.0)
The stack trace shows the crash happens at WK.Libraries.SharpClipboardNS.Views.ClipboardHandle.WndProc. This is a classic race condition between apps probably. Try wrap the clipboard access in a try-catch block with a small "retry" loop (e.g., try 3 times with a 100ms delay between attempts). Since SharpClipboard uses a "Clipboard Viewer" or "Clipboard Monitor" hook. When it receives a message that the clipboard has changed, it immediately tries to read it, often before the application that put the data there has finished closing the clipboard handle.
Outline
An unhandled exception occurs when the application attempts to access the clipboard, likely due to a race condition or the clipboard being locked by another process.
Reproduction Steps:
Error message
Environment:
Loaded Assemblies (Summary):
The stack trace shows the crash happens at
WK.Libraries.SharpClipboardNS.Views.ClipboardHandle.WndProc. This is a classic race condition between apps probably. Try wrap the clipboard access in atry-catchblock with a small "retry" loop (e.g., try 3 times with a 100ms delay between attempts). SinceSharpClipboarduses a "Clipboard Viewer" or "Clipboard Monitor" hook. When it receives a message that the clipboard has changed, it immediately tries to read it, often before the application that put the data there has finished closing the clipboard handle.