_原始作者:cheaster ... @ gmail.com(2010年12月7日14:58:50)_
哪些步骤将重现该问题?
什么是预期的输出?
预期的输出将是添加到datagrid的克隆数据。 在DragOver和Drop事件中,我将处理任何数据问题。 但是,我从来没有走过这么远,因为O / S在GongSolutions.Wpf.DragDrop.DropInfo.cs(代码为Data =(e。 Data.GetDataPresent(dataFormat))?e.Data.GetData(dataFormat):e.Data;)。
您正在使用什么版本的产品?
0.1.3(汇编版本)-我是从源代码构建的
Windows XP
请在下面提供任何附加信息。
异常详细信息如下:
用户代码未处理System.Runtime.InteropServices.COMException
消息=输入无效的字符(HRESULT的异常:0x80040069(DV_E_TYMED))
来源= mscorlib
错误代码= -2147221399
堆栈跟踪:
在System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode,IntPtr errorInfo)
在System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
在System.Windows.DataObject.System.Runtime.InteropServices.ComTypes.IDataObject.GetData(FORMATETC&formatetc,STGMEDIUM&medium)
在System.Runtime.InteropServices.ComTypes.IDataObject.GetData(FORMATETC和格式,STGMEDIUM和介质)中
在System.Windows.DataObject.OleConverter.GetDataInner(FORMATETC&formatetc,STGMEDIUM&medium)
在System.Windows.DataObject.OleConverter.GetDataFromOleHGLOBAL(字符串格式,DVASPECT方面,Int32索引)
在System.Windows.DataObject.OleConverter.GetDataFromBoundOleDataObject(字符串格式,DVASPECT方面,Int32索引)
在System.Windows.DataObject.OleConverter.GetData(字符串格式,布尔值自动转换,DVASPECT方面,Int32索引)
在System.Windows.DataObject.OleConverter.GetData(字符串格式,布尔值自动转换)
在System.Windows.DataObject.GetData(字符串格式,布尔值autoConvert)
在System.Windows.DataObject.GetData(字符串格式)
在GongSolutions.Wpf.DragDrop.DropInfo..ctor(对象发送者,DragEventArgs e,DragInfo dragInfo)
在GongSolutions.Wpf.DragDrop.DragDrop.DropTarget_PreviewDragOver(Object sender,DragEventArgs e)
在GongSolutions.Wpf.DragDrop.DragDrop.DropTarget_PreviewDragEnter(Object sender,DragEventArgs e)
在System.Windows.DragEventArgs.InvokeEventHandler(委托genericHandler,对象genericTarget)
在System.Windows.RoutedEventArgs.InvokeHandler(委托处理程序,对象目标)处
在System.Windows.RoutedEventHandlerInfo.InvokeHandler处(对象目标,RoutedEventArgs routedEventArgs)
在System.Windows.EventRoute.InvokeHandlersImpl(对象源,RoutedEventArgs参数,布尔重新引发)
在System.Windows.UIElement.RaiseEventImpl(DependencyObject sender,RoutedEventArgs args)
在System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
在System.Windows.OleDropTarget.RaiseDragEvent上(RoutedEvent dragEvent,Int32 dragDropKeyStates,Int32&效果,DependencyObject目标,Point targetPoint)
在System.Windows.OleDropTarget.MS.Win32.UnsafeNativeMethods.IOleDropTarget.OleDragOver(Int32 dragDropKeyStates,Int64 Point,Int32&效果)
InnerException:
_原始问题: http :
_来自cheaster ... @ gmail.com,2010年12月7日15:25:00_
更多信息...。
似乎真正的问题是当我将IDragInfo.Data设置为System.Windows.DataObject对象时。 我将附加一个示例应用程序来演示该问题。
要查看该错误,请执行以下步骤。 运行该应用程序的两个实例,尝试从两个实例之间的列表框中拖动一个项目。
我使用DataObject的原因是我还需要允许将文件拖放到O / S。
_发自fahad ... @ gmail.com,2011年8月24日20:46:51_
在此添加您的声音以解决此问题
https://connect.microsoft.com/WPF/feedback/details/682826/comexception-of-type-dv-e-tymed-occurs-when-a-break-point-hit-as-a-result-of-拖曳
我正在开发的应用程序中遇到DV_E_TYMED异常问题,我想分享我找到的解决方案。 在此附件中,您可以找到我为解决此问题而修改的项目中的文件。
基本上,将对象从一个应用程序拖到另一个应用程序时,需要使用COM,并且COM要求对象必须可序列化才能正确交换。
使用DataObject时,您不能仅传递您创建的DataFromat,因为COM对此一无所知。 相反,我创建了一个包装器类(DragDropDataWrapper),该类被标记为[Serializable]并实现ISerializable。 然后,每次我需要创建一个DataObject时,我都会做:new DataObject(new DragDropDataWrapper(data))。 在另一方面,我现在可以使用DataFormat.Serializable来检索我的数据,它是COM可以识别的。
我必须修复其他次要问题才能使示例工作,即管理DragInfo为null的情况。
如果您查看BoundTree示例,它现在应该可以跨应用程序运行。
CrossApplicationDragDropFix.zip
最有用的评论
我正在开发的应用程序中遇到DV_E_TYMED异常问题,我想分享我找到的解决方案。 在此附件中,您可以找到我为解决此问题而修改的项目中的文件。
基本上,将对象从一个应用程序拖到另一个应用程序时,需要使用COM,并且COM要求对象必须可序列化才能正确交换。
使用DataObject时,您不能仅传递您创建的DataFromat,因为COM对此一无所知。 相反,我创建了一个包装器类(DragDropDataWrapper),该类被标记为[Serializable]并实现ISerializable。 然后,每次我需要创建一个DataObject时,我都会做:new DataObject(new DragDropDataWrapper(data))。 在另一方面,我现在可以使用DataFormat.Serializable来检索我的数据,它是COM可以识别的。
我必须修复其他次要问题才能使示例工作,即管理DragInfo为null的情况。
如果您查看BoundTree示例,它现在应该可以跨应用程序运行。
CrossApplicationDragDropFix.zip