Occasional "System.Exception: OpenClipboard Failed (Exception from HRESULT: 0x800401D0)"

Hong 1,186 Reputation points
2024-06-13T08:40:09.66+00:00

An app occasionally throws the following exception:

System.Exception: OpenClipboard Failed (Exception from HRESULT: 0x800401D0)
 Stack Trace:
   at System.Runtime.InteropServices.McgMarshal.ThrowOnExternalCallFailed(Int32, RuntimeTypeHandle) + 0x21
   at __Interop.ComCallHelpers.Call(__ComObject, RuntimeTypeHandle, Int32, Void*) + 0xbe
   at __Interop.ForwardComStubs.Stub_9[TThis, TArg0](__ComObject, TArg0, Int32) + 0x5a
   at ClassLibraryUno.Utility.<>c__DisplayClass119_0.<CopyToClipboard>b__0() + 0x34
   at Windows.Foundation.DeferralCompletedHandler.Invoke() + 0x25
   at Camera_Alternative!<BaseAddress>+0x28dfd9c


DataPackage dp = new DataPackage();
dp.SetText(sText);
await dispatcher.RunAsync(
    CoreDispatcherPriority.Normal,
    () =>
    {
        Clipboard.SetContent(dp);
    });

Could anyone offer a tip on the possible cause?

Universal Windows Platform (UWP)
{count} votes