C# Clipboard with Reflection question

D

dmeglio

I have an item that I placed on the clipboard as follows:
Clipboard.SetDataObject(slide);
slide is type SlideType.

Now I'm trying to read the data from the clipboard doing:

foreach (System.Type type in this.slideModules.Values)
{
if (Clipboard.GetDataObject().GetDataPresent(type))
{
Clipboard.GetDataObject().GetData(type);
break;
}
}

However, on the GetData() line, I receive a FileNotFoundException
claiming that SlideType was not found. I suspect the issue is that
SlideType is actually loaded via reflection (it's in a dll I'm loading
at runtime). Is there anyway to get the clipboard to work with types
loaded through reflection?
 
S

Stoitcho Goutsev \(100\)

It depends on the the type of the object in the clipboard, If the object
cannot be represented with one of the standard clipboard formats the object
is serialized. In order to be deserialized on the reading side the consumer
of this object has to know this type.
 
D

dmeglio

Yeah, it will need to be deserialized. The object is marked as
Serializable. Is there anyway I can provide the "consumer" with the
information it needs to deserialize it?

Thanks for the help.
 
S

Stoitcho Goutsev \(100\)

The client application needs to reference a dll with declaration of the
type.
 
D

dmeglio

Well the client app handling the paste is the one that executed the
copy. So if it has the information such that it can put the object on
the clipboard (serialize it) shouldn't it have enough information to
take it off (deserialize it)? Or am I missing something?
 
S

Stoitcho Goutsev \(100\)

Yes, it should.
Can you post some simple compilable sample that demonstratest the porblem?
 

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