我正在尝试从我的应用程序的Winforms部分拖动数据包含在"ElementHost"中的WPF控件上.当我尝试这样做时它会崩溃.
尝试相同的东西,但从Winforms到Winforms工作正常.(参见下面的示例代码)
我需要帮助才能完成这项工作......有什么线索我做错了什么?
谢谢!
示例:
在下面的示例代码中,我只是尝试拖动在标签控件上启动拖动时创建的自定义MyContainerClass对象1)System.Windows.Forms.TextBox(Winforms)和2)System.Windows.TextBox (WPF,添加到ElementHost).
情况1)工作正常但案例2)在尝试使用GetData()检索丢弃数据时崩溃.GetDataPresent("WindowsFormsApplication1.MyContainerClass")返回"true"所以从理论上讲,我应该能够像在Winforms中那样检索那种类型的drop数据.
这是崩溃的堆栈跟踪:
"Error HRESULT E_FAIL has been returned from a call to a COM component" with the following stack trace: at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) at System.Windows.Forms.DataObject.GetDataIntoOleStructs(FORMATETC& formatetc, STGMEDIUM& medium) at System.Windows.Forms.DataObject.System.Runtime.InteropServices.ComTypes.IDataObject.GetDataHere(FORMATETC& formatetc, STGMEDIUM& medium) at System.Windows.Forms.DataObject.System.Runtime.InteropServices.ComTypes.IDataObject.GetData(FORMATETC& formatetc, STGMEDIUM& medium) at System.Windows.DataObject.OleConverter.GetDataInner(FORMATETC& formatetc, STGMEDIUM& medium) at System.Windows.DataObject.OleConverter.GetDataFromOleHGLOBAL(String format, DVASPECT aspect, Int32 index) at System.Windows.DataObject.OleConverter.GetDataFromBoundOleDataObject(String format, DVASPECT aspect, Int32 index) at System.Windows.DataObject.OleConverter.GetData(String format, Boolean autoConvert, DVASPECT aspect, Int32 index) at System.Windows.DataObject.OleConverter.GetData(String format, Boolean autoConvert) …