在桌面上拖动文件时可能导致 COMExceptions 的原因是什么?

What could possibly cause COMExceptions while dragging file over the Desktop?

它没有崩溃,我在这里提到的所有异常只能在Visual Studio的输出window中看到。下面是拖动的实现:
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);
}

一切似乎都按预期工作,但每次我在桌面或资源管理器上拖动某些东西时 window 我在 Visual Studio 的输出 window 中收到以下消息:

...
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 问题看起来很像我的,但似乎有其他原因和解决方案。

这是完全正常的。无论您拖动另一个进程的 window 什么,都会使该进程戳您拖动的对象以查看它是否支持特定格式或是否可以将对象转换为另一种格式。在引擎盖下完成 COM calls。如果答案是 "yes",那么您会看到光标发生变化,表示您可以放下。

WPF 中的 IDataObject 接口实现通过抛出异常表示 "no"。在 .NET 程序中生成 COM 故障代码的正常方式。该异常由 CLR 转换为 COM 错误代码,即 HRESULT,以告知进程它不会工作。请注意 Exeption class 如何具有 HResult property,这就是进程所看到的。

如果您要求,调试器会尽职地显示 "first chance" 异常通知。右击输出window、"Exception Messages"选项,默认开启。实际上没有任何问题,异常被捕获并被优雅地处理。功能,不是错误。