Maximum C#

May 4, 2009

Clipboard Madness

Filed under: Programming — Tags: — .:: Bishoy™ ::. @ 3:05 PM

Folks, with all the evolution among .NET framework and its programming languages and with myself beeing fond with C# in particular… I faced a very strange problem in the framework when trying to copy an object to the clipboard and then when I retreive it back I found that there are some data missing

so here is my object in pseudo code:

[serializable]
class A
{
property A1;
property A2;
}

[serializable]
class B : A
{
property B1;
property B2;

property B3;
}

so I’m trying to put an instance of class B into the clipboard, and when I retrive it back from the clipboard I find that (B.A1 = null) in the mean time I’m sure that it has data at the time I put it in the clipboard and I was stepping through the code line by line and reading the object property values before and after the clipboard set/get

and to make the story even more weired here is the killer solution that solved the problem for me: I put a clone of my object in the clipboard, not the object itself and that worked like a charm and the data is retreived correctly.

I’m just wondering if Clipboard is referencing my object directly so that when I modify the object I sent to the clipboard it does get modified in the clipboard, or its just my imagination!!

anyway, I’ll keep you guys updated on any news for this issue.

Theme: Silver is the New Black. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.