Problem with IDataObject

D

dmeglio

I have the following code:

foreach (System.Type type in this.slideModules.Values)
{
IDataObject ido = Clipboard.GetDataObject();
if (ido.GetDataPresent(type))
{
slide = ido.GetData(type) as RC.Objects.RCSlideBase;
break;
}
}

The GetDataPresent returns true. However, the GetData returns null. Any
clue what might cause such a situation?
 
N

Nicholas Paldino [.NET/C# MVP]

You can have a variety of formats on the clipboard, it doesn't just have
to be yours. It would seem that this.slideModules.Values is returning a
type which is not derived from RC.Objects.RCSlideBase.

Hope this helps.
 
D

dmeglio

Well it is derived from RCSlideBase, it has nothing to do with the
cast. I used the VS.NET debugger to see that ido.GetData(type) returns
null.

I understand that the clipboard can contain multiple types. However, I
did a ido.GetDataPresent(type), since that returned true, doesn't that
mean that _type_ is on the clipboard, hence GetData(type) should return
something?

You can have a variety of formats on the clipboard, it doesn't just have
to be yours. It would seem that this.slideModules.Values is returning a
type which is not derived from RC.Objects.RCSlideBase.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I have the following code:

foreach (System.Type type in this.slideModules.Values)
{
IDataObject ido = Clipboard.GetDataObject();
if (ido.GetDataPresent(type))
{
slide = ido.GetData(type) as RC.Objects.RCSlideBase;
break;
}
}

The GetDataPresent returns true. However, the GetData returns null. Any
clue what might cause such a situation?
 
G

Greg Young

Does the actual call return null i.e.

object o = ido.GetData(type);
o == null

or does

slide = ido.GetData(type) as RC.Objects.RCSlideBase;
slide == null

Cheers,

Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top