My app uses the Copy()
method of DataGrid
to retrieve all data for exporting to CSV and other formats. All I do is
- Clear the Clipboard
- Call
myGrid.Copy()
Now that usually works fine - except for <1% of my users they receive an exception.
Even on these particular systems it happens only occasionally, i.e. copying works the first time but then fails on following attempts (that is, with identical, valid table contents copying works 1 out of 3 times!) with a CLIPBRD_E_CANT_OPEN
error and stack traces like
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at System.Windows.Clipboard.Flush()
at System.Windows.Controls.DataGrid.OnExecutedCopy(ExecutedRoutedEventArgs args)
The .net Version is usually 4.0.30319.x (but again the problem doesn't appear to be related to a particular framework version as far as I can tell).
As the export is a crucial feature of the app this problem has a pretty huge impact..
Any ideas how to work around this problem would be much appreciated!