views:

30

answers:

2

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?

+1  A: 

ArrayList is serializable. While you lose the strong typing, you can always cast on the way out.

MCain
That might be an option. Although I would prefer a solution that retain the type information.
gencha
In that case, use a straight array of type Slide.
MCain
@MCain: Yeah, that completely slipped my mind. But it turns out `List` actually does work. My mistake.
gencha
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