I have a few problem with the Windows Clipboard in my WPF desktop application. I try to retrieve clipboard content, do something (without write on this content, only read), and re-send the content into clipboard. It run, but after re-send the content, if I retrieve clipboard content and try to read again, I have an OutOfMemory exception.
After search, I've found this link : http://www.grumpydev.com/2009/09/05/system-outofmemoryexception-gotcha-using-clipboard-getdata-in-wpf/
It's maybe because of a serialization problem, I think that my data loose his serialisation attribut or else when I send it into the clipboard.
Here is my code :
var data = System.Windows.Clipboard.GetDataObject();
// Read "data"
System.Windows.Clipboard.Clear();
System.Windows.Clipboard.SetDataObject(data, true);
var dataTwo = System.Windows.Clipboard.GetDataObject();
// Read "dataTwo" ==> OutOfMemoryException
Notice that the data has not a Type of my project, it can be everything (photoshop, excel, picture, text, binary...)
Anyone has an idea to correct this?
Thank you un advance