none
Requested Clipboard operation did not succeed.

    Question

  • This is a small Console app. In a loop it listens on a named pipe. When it gets a string on the pipe it puts it on the user's clipboard with Clipboard.SetText(accn); On my computer, no problem. On another user's computer it works a few times then gets this error.

    Why? How can I make it work?

    Thanks,


    Jon Jacobs
    This message was composed entirely from recycled electrons.
    Friday, May 06, 2011 12:03 AM

Answers

  • Hi Jon,

    >I think the difference was that I always pasted the text into some app such as Notepad, and he didn't

    How did the user deal with the string in clipboard if he didn't pasted the text into app? And how about trying the clear() method? Does it solve your problem?

    Based on your description, I cannot repro your secnario. And it is hard for me to test. Can you provide your code if it is convenient for you? Thanks. 


    Vin Jin [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Jon Q Jacobs Thursday, May 19, 2011 12:59 PM
    Wednesday, May 11, 2011 6:35 AM

All replies

  • The problem with the clipboard is that it is shared among all processes and only one process can access it at a time. So if another process uses the clipboard at the same time as your application then you may get this exception. Your other computer may have a process that uses the clipboard even when the process's window is not active (e.g. the user is performing an action in your application). This is also known to be a problem with Virtual machines.

    My advice is to catch the exception and try again a few times, sooner or later the clipboard will be freed so you could use it. You could inherit from the Clipboard class and provide additional methods that you use in your application.

    /Calle


    - Still confused, but on a higher level -
    Friday, May 06, 2011 8:33 AM
  • Weird. There is no evidence any other app is using the clipboard. The only thing that happens is that the user does a Ctrl-V to paste the text into something else, such as notepad.

    As for the other computer, how could it affect the user's computer? For that matter, the process on the other machine (a server) that sends the data is running in a service environment that has no clipboard.

    I will use try catch and see what happens.

    Thanks,


    Jon Jacobs
    This message was composed entirely from recycled electrons.
    Friday, May 06, 2011 1:31 PM
  • Interesting thread. I will use Clear() as well as try - catch, although my understanding of the Windows clipboard (not the Office clipboard) is that each time something is put on, the previous content is removed.

    Thanks,


    Jon Jacobs
    This message was composed entirely from recycled electrons.
    Friday, May 06, 2011 1:34 PM
  • Hi Jon,

    >On another user's computer it works a few times then gets this error.

    I am not sure what is the difference between these computers? Does it happen in other computer?

    I think you can try the Clipboard.SetDataObject method to have a try.

    Here is a similar thread you can refer to:
    http://social.msdn.microsoft.com/forums/en-US/Vsexpressvb/thread/a23c31df-e645-4500-ab4a-e6178510a9b1


    Vin Jin [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, May 10, 2011 4:08 AM
  • >I am not sure what is the difference between these computers

    I think the difference was that I always pasted the text into some app such as Notepad, and he didn't


    Jon Jacobs
    This message was composed entirely from recycled electrons.
    Tuesday, May 10, 2011 1:26 PM
  • Hi Jon,

    >I think the difference was that I always pasted the text into some app such as Notepad, and he didn't

    How did the user deal with the string in clipboard if he didn't pasted the text into app? And how about trying the clear() method? Does it solve your problem?

    Based on your description, I cannot repro your secnario. And it is hard for me to test. Can you provide your code if it is convenient for you? Thanks. 


    Vin Jin [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Jon Q Jacobs Thursday, May 19, 2011 12:59 PM
    Wednesday, May 11, 2011 6:35 AM
  • >How did the user deal with the string in clipboard if he didn't pasted the text into app

    He was testing.

    >And how about trying the clear() method?

    My understanding of putting things on the clipboard was that it always cleared the previous entry. Nevertheless I added that and trapped the error silently and I exit the app and restart after every use. That worked.

    Thanks,

    Jon


    Jon Jacobs
    This message was composed entirely from recycled electrons.
    • Marked as answer by Jon Q Jacobs Monday, May 23, 2011 12:25 PM
    • Unmarked as answer by Jon Q Jacobs Monday, May 23, 2011 12:25 PM
    Tuesday, May 17, 2011 12:20 PM
  • Hi Jon,

    It seems that the Clear() method can help you solve your problem. If it does, plese mark the useful reply as answer. Thanks.

    If you still have problem, we are gald to help you. Thanks.


    Vin Jin [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, May 18, 2011 8:24 AM