OneMore icon indicating copy to clipboard operation
OneMore copied to clipboard

CopyAsTextCommand report an error!!

Open mengxin523 opened this issue 1 year ago • 12 comments

ShareX-2024-01-25 17-26-47 1067

17| hashtag service scanned 3437 pages, updating 0, in 162050ms 10| hashtag service scanned 3437 pages, updating 0, in 162083ms 16| hashtag service scanned 3437 pages, updating 0, in 162013ms 16| hashtag service scanned 3437 pages, updating 0, in 162174ms 18| Running command SettingsCommand 10| Running command AboutCommand 03| hashtag service scanned 3437 pages, updating 0, in 162096ms 18| hashtag service scanned 3437 pages, updating 0, in 161965ms 14| hashtag service scanned 3437 pages, updating 0, in 161810ms 15| Running command CopyAsTextCommand 07| 运行命令CopyAsTextCommand时出错 07| System.Runtime.InteropServices.COMException Message: OpenClipboard 失败 (异常来自 HRESULT:0x800401D0 (CLIPBRD_E_CANT_OPEN)) Description: Unrecognized error code 0x800401D0 ErrorCode: 0x800401D0 (-2147221040) HResult: 0x800401D0 (-2147221040) Source: mscorlib StackTrace: 在 System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) 在 System.Windows.Clipboard.Flush() 在 System.Windows.Clipboard.CriticalSetDataObject(Object data, Boolean copy) 在 System.Windows.Clipboard.SetDataInternal(String format, Object data) 在 River.OneMoreAddIn.ClipboardProvider.<>c__DisplayClass15_0.<SetText>b__0() 在 River.OneMoreAddIn.SingleThreaded.<>c__DisplayClass1_0.<Invoke>b__0() --- 引发异常的上一位置中堆栈跟踪的末尾 --- 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 在 System.Runtime.CompilerServices.TaskAwaiter.GetResult() 在 River.OneMoreAddIn.ClipboardProvider.<SetText>d__15.MoveNext() --- 引发异常的上一位置中堆栈跟踪的末尾 --- 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 在 System.Runtime.CompilerServices.TaskAwaiter.GetResult() 在 River.OneMoreAddIn.Commands.CopyAsTextCommand.<Execute>d__1.MoveNext() --- 引发异常的上一位置中堆栈跟踪的末尾 --- 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 在 System.Runtime.CompilerServices.TaskAwaiter.GetResult() 在 River.OneMoreAddIn.CommandFactory.<Run>d__5.MoveNext() TargetSite: [mscorlib] System.Runtime.InteropServices.Marshal::ThrowExceptionForHRInternal()

OneNote2024 OneMore6.1 ShareX-2024-01-25 17-28-14 1069

mengxin523 avatar Jan 25 '24 09:01 mengxin523

You can try to fix it in two ways: 1.open Local Security Policy ; navigate to Security Settings > Local Policies > Security Options > System cryptography: Use FIPS compliant algorithms for encryption, hashing, and signing ; Disable it

2.open regedit ; Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy ; change both values "Enabled" and "MDMEnabled" to 0

ningdu0 avatar Jan 25 '24 09:01 ningdu0

You can try to fix it in two ways: 1.open Local Security Policy ; navigate to Security Settings > Local Policies > Security Options > System cryptography: Use FIPS compliant algorithms for encryption, hashing, and signing ; Disable it

2.open regedit ; Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy ; change both values "Enabled" and "MDMEnabled" to 0

Very feel your reply, I just logged in to the system to see, the option on the local security policy was originally disabled, and the value in the registry was originally 0, but the problem still exists,I even restart the system ShareX-2024-01-25 19-44-37 1071 ShareX-2024-01-25 19-45-05 1072

mengxin523 avatar Jan 25 '24 11:01 mengxin523

@ningdu0 FIPs only affects TLS validation. This is a problem accessing the clipboard. Other users have seen this in the past.

@mengxin523 Do you have any other utilities running that monitor or watch the clipboard?

stevencohn avatar Jan 25 '24 11:01 stevencohn

@ningdu0 FIPs only affects TLS validation. This is a problem accessing the clipboard. Other users have seen this in the past.

@mengxin523 Do you have any other utilities running that monitor or watch the clipboard?

No, everything was normal before, but I don't know why things suddenly have problems, I don't know whether it has something to do with my updated Office2024

mengxin523 avatar Jan 25 '24 11:01 mengxin523

I realize this is marked as both next-release and no-repro. While I wasn't able to repro the issue, I added some extra error handling to at least make the error more obvious.

stevencohn avatar Jan 25 '24 17:01 stevencohn

I realize this is marked as both next-release and no-repro. While I wasn't able to repro the issue, I added some extra error handling to at least make the error more obvious.

Although it will report this error, in fact the copy function is normal and can be pasted elsewhere as text instead of pictures!! This means that there is no need to show this error.

mengxin523 avatar Jan 26 '24 01:01 mengxin523

I know the problem is because I used Baidu Netdisk to synchronize data in real time, and Baidu Netdisk's synchronization space monitors the clipboard. If I turn off this option, the error will not be displayed!

Otherwise, although it will report an error, but it does not affect the use of the copy function.

mengxin523 avatar Jan 26 '24 01:01 mengxin523

ShareX-2024-01-26 09-55-27 1073

mengxin523 avatar Jan 26 '24 01:01 mengxin523

Just to add to this @stevencohn I disabled my clipboard watcher in my app, but the copy Link to Para is doing the same thing 9copying a plain text URI rateher than a formatted HTML link and I can make it happen to order on enabling and disabling the app: AutoHotkey

jasonjac2 avatar Jan 31 '24 11:01 jasonjac2

Food for thought https://stackoverflow.com/questions/930219/how-to-handle-a-blocked-clipboard-and-other-oddities

stevencohn avatar Jan 31 '24 11:01 stevencohn

Indeed - a couple of potential solutions. I like the - be patient and then tell the user which app is hogging the clipboard.

jasonjac2 avatar Jan 31 '24 11:01 jasonjac2

Going try switching from System.Windows.Clipboard to System.Windows.Forms.Clipboard which provides retry out of the box.

Commit details here - https://github.com/stevencohn/OneMore/commit/7dd8c4c694431fb0872615345de999b16ac8e825

stevencohn avatar Jan 31 '24 21:01 stevencohn