Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Drag and drop between 2 listboxes, COMException

$
0
0

Hi,

This problem occurs every now and then when I drag one element from ListBox to the other listbox. "Error HRESULT E_FAIL has been returned from a call to a COM component." COMException is thrown when I call "DragDrop.DoDragDrop". The code below shows how and where exactly I call DoDragDrop.

object[] parameters = { source, data }; Dispatcher.CurrentDispatcher.BeginInvoke(

new Action(() => DoDragDrop(parameters))

, System.Windows.Threading.DispatcherPriority.Background, null);

where DoDragDrop(parameters) is: public static void DoDragDrop(params object[] list) { //try //{ DragDrop.DoDragDrop(list[0] as DependencyObject, list[1], DragDropEffects.Move); //} //catch //{ //} }


I've read about similar problems being resolved by doing the drag and drop asynchronously hence the Dispatcher call. Still the problem persists. Catching all the exceptions helps - it works properly from what I can notice - which suggests that the exception doesn't break the drag and drop operation. I would prefer to know and eliminate the cause. I'd appreciate any help.

Best regards,

Simon




Viewing all articles
Browse latest Browse all 18858

Trending Articles