I have made a WPF application that allows drag and drop of instances of a class I made (FakeNodeViewModel
). It works fine when I work with only one instance of my application. But when I use 2 and I try to drag objects from one and drop on the other, I get an exception when dropping:
System.Runtime.InteropServices.COMException: 'Tymed non valide (Exception de HRESULT : 0x80040069 (DV_E_TYMED))'
and the two instances crash. My method to handle drop starts like this:
private void grid_Drop(object sender, DragEventArgs e) {
if (e.Data.GetDataPresent("fakeNode")) {
var fakeNodeViewModel = (FakeNodeViewModel)e.Data.GetData("fakeNode");
and the program crash at var fakeNodeViewModel = (FakeNodeViewModel)e.Data.GetData("fakeNode");
I didn't find a lot about this. Does anyone know what happen and how to solve it ?
You should decorate the FakeNodeViewModel
class with the System.SerializableAttribute
for it be COM serializable:
[Serializable]
public class FakeNodeViewModel
{
...
}