1

I use an external program, which works with the clipboard interface, to pass parameters and open patients. The case is that I am doing a program in vb.net in which I pass the parameters to that external program using the clipboard, with this line:

My.Computer.Clipboard.SetText (myTextWithParameters)

and the external application which is always running, gets that data and returns some values. But the problem is that in my vb.net application when inserting the line My.Computer.Clipboard.SetText (textClipboardInfo), I directly skip an error:

Catch ex As Exception
    MessageBox.Show (ex.GetType (). FullName)
    MessageBox.Show (ex.Message.ToString)
End Try

In the ex.GetType (). FullName -> I get the following: System.Runtime.InteropServices.ExternalException.

I think this is because there is another process that is using the clipboard, which in this case is my external program, but I can not close it because it has to be running to be able to pass the parameters.

I hope I have made myself clear.

Any help is appreciated.

Andrii Litvinov
  • 12,402
  • 3
  • 52
  • 59
Esraa_92
  • 1,558
  • 2
  • 21
  • 48
  • 1
    Try adding a small delay before you get the value. Also check this SO out: http://stackoverflow.com/questions/930219/how-to-handle-blocked-clipboard-and-other-oddities – Botonomous Apr 17 '17 at 13:02
  • 3
    Here is a very good answer on why clipboard is not very good way of exchanging data between processes http://stackoverflow.com/a/20193276/920557. There are plenty other options out there like memory mapped files, WCF, etc. If you are locked to usage of the clipboard and ready to deal with all the side effects it introduces you should consider adding cross process synchronization of the reads and writes as well as powerful retry mechanism to avoid unhanded exceptions. Hope it helps! – Eugene Komisarenko Apr 17 '17 at 13:13

0 Answers0