Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
Failed to copy, CLIPBRD_E_CANT_OPEN

A user was trying to copy(which normally works fine) and got the exception:

System.Runtime.InteropServices.COMException (0x800401D0): OpenClipboard Failed (Exception from HRESULT: 0x800401D0 (CLIPBRD_E_CANT_OPEN))

   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)

   at System.Windows.Clipboard.CriticalSetDataObject(Object data, Boolean copy)

   at System.Windows.Clipboard.SetDataObject(Object data, Boolean copy)

   at Infragistics.Windows.Helpers.ClipboardHelper.SetDataObject(Object data, Boolean copy)

   at Infragistics.Windows.DataPresenter.ClipboardOperationInfo.CopyToClipboard(ICellValueProvider provider)....


Has anyone else seen this? Shouldn't the datapresenter be able to catch and handle this exception?

  • 54937
    Offline posted

    Yes technically only 1 process can open the clipboard so if another process has it opened the subsequent requests will fail until the first releases the clipboard. This was sort of handled in the WinForms Clipboard class where it would retry the set with a delay in between each try but the WPF clipboard class doesn't do this so if it fails on the first show the exception occurs. Even then we should probably catch the exception and raise the clipboard operation error if it still fails. I'll see about getting this written up and get a case created for you for this. In the interim if you wanted to get around this you could possibly work around this by handling the DataObject.Copying attached event on the DP, calling CancelCommand on the event args so the DP doesn't perform the operation and then handle setting the data on the clipboard.