【发布时间】:2016-03-09 15:16:11
【问题描述】:
它不会崩溃,我在这里提到的所有异常只能在 Visual Studio 的输出窗口中看到。这是拖动的实现:
WPF:
<StackPanel Orientation="Vertical"
MouseDown="DragShortcut"
x:Name="Shortcut">
<Image Source="{Binding Icon}"/>
<Label Content="{Binding ShortcutLabel}"/>
</StackPanel>
cs代码:
private void DragShortcut(object sender, MouseButtonEventArgs e)
{
if (e.LeftButton != MouseButtonState.Pressed)
return;
var dataObject = new DataObject(DataFormats.FileDrop, new[] { Options.DragDropOptions.ShortcutPath });
DragDrop.DoDragDrop(Shortcut, dataObject, DragDropEffects.Copy);
}
一切似乎都按预期工作,但每次我在桌面或资源管理器窗口上拖动某些东西时,我都会在 Visual Studio 的输出窗口中收到以下消息:
...
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll
A first chance exception of type 'System.NotImplementedException' occurred in PresentationCore.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll
...
当 Visual Studio 设置为停止此类异常时,我可以看到以下异常:
System.Runtime.InteropServices.COMException was unhandled
Message: An exception of type 'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll and wasn't handled before a managed/native boundary
Additional information: Invalid FORMATETC-Structure (Exception HRESULT: 0x80040064 (DV_E_FORMATETC))
和
System.NotImplementedException was unhandled
Message: An exception of type 'System.NotImplementedException' occurred in PresentationCore.dll and wasn't handled before a managed/native boundary
Additional information: The method or operation is not implemented.
这不会导致崩溃或任何事情,作为一名开发人员,在后台发生这样的事情让我感到不舒服。有没有人有一个想法是什么?
编辑:
This 问题看起来很像我的,但似乎有另一个原因和解决方案。
【问题讨论】:
-
@TheLethalCoder 异常是相似的,尽管在我的情况下它似乎有另一个原因。
标签: c# wpf drag-and-drop drag comexception