Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

i am using the clipboard to copy and paste text on the textcontrol. Which seems to work fine on some computers well as others it throws me the following error.

 

Cannot read from or write to the clipboard (01-1603)

 

throwkernelerror

 

 

One thought I had was after each paste of the text or before I set the dataobject in the clipboard, i call the garbage collector. My thought is that something the computer is doing is locking the clipboard and calling the garbage collection will free the clipboard up.

  • Leaders
Posted

This begs the question: why are you calling the garbage collector. As long as you know that this is supposed to be automated and understand the implications of explicitly invoking a garbage collection (under most circumstances it will actually cause the garbage collector to perform less efficiently), or in other words, if you really know what you are doing, then do what you will, but I'd recommend you avoid calling the garbage collector explicitly.

 

If you must call the garbage collector, I don't know the finer details but it could be that something relating to the ClipBoard class is pinned or being moved or something. I don't know if code is allowed to be executed during a collection. If that is the case, you might want to try to do an Application.DoEvents after the call to GC.Collect to allow the GC thread to finish up. Otherwise, I don't know what to tell you.

[sIGPIC]e[/sIGPIC]
Posted
I am not calling the garbage collector as of yet, it was just an ideal I had, I thought that something was still using the clipboard and the program was not giving the clipboard enough time to do what it needed to do. Garbage collection i would force it to clean itself up. Not sure what else to try. Some computers I have no problem to use the clipboard for copying and pasting. While still others I get the error. Any thoughts?
Posted
Are all of the test PC's using the same version of windows, or are the PC's running a certain version of Windows not working correctly?
Anybody looking for a graduate programmer (Midlands, England)?
Posted
Yes all the systems are running the exact same version of the Windows and the exact same version of the application and all the pc's are the same as far as hardware and brand.
  • Leaders
Posted
My bad. I guess I should pay attention when I read a post. I thought you said that you were forcing garbage collections. But have you tried calling Application.DoEvents to let other threads finish what they are doing before accessing the clipboard? I don't see why it should be necessary, but who knows?
[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...