I have a class Slide
, of which I want to place several instances in the clipboard. It works perfectly fine for a single instance.
But when I try to, for example, put a List<Slide>
in the clipboard, the SetDataObject
call will silently fail.
Internally, a COMException will be thrown and is swallowed. This is because List
does not implement ISerializeable
.
So, List<T>
seems not to be an option. What would be the proper approach to place a collection of Slide
instances in the clipboard?
views:
30answers:
2
+1
A:
ArrayList is serializable. While you lose the strong typing, you can always cast on the way out.
MCain
2010-07-21 18:56:52
That might be an option. Although I would prefer a solution that retain the type information.
gencha
2010-07-21 19:03:46
In that case, use a straight array of type Slide.
MCain
2010-07-21 19:15:15
@MCain: Yeah, that completely slipped my mind. But it turns out `List` actually does work. My mistake.
gencha
2010-07-21 19:20:52
A:
Turns out my assumptions were incorrect. I simply forgot a ToList()
call and was only passing in the IEnumerable
to SetData
. After adding that, it is put into the clipboard just fine.
gencha
2010-07-21 19:15:15