Clipboard operations fail using Tight VNC

2.5k Views Asked by At

I have written a c# code to run on a vps, in which I have used Clipboard class. When I am monitoring the vps using vnc-viewer (tight vnc) the Clipboard-based operations fail. But it works fine with team viewer.

I also disabled clipboard transfer option on the vnc viewer, but the problem still existed.

2

There are 2 best solutions below

0
On

I have found that various VNC programs are blocking clipboard. This is my solution written in C# for .NET 3.5:

using System.Threading;

   var dataObject = new DataObject();
   private Clipboard()
   {
        //dataObject logic here

        Thread clipboardThread = new Thread(new ThreadStart(GetClipboard));
        clipboardThread.SetApartmentState(ApartmentState.STA);
        clipboardThread.Start();
   }

   private void GetClipboard()
   {
         Clipboard.SetDataObject(dataObject, true, 10, 100);
   }
1
On

Copy/paste to work add these

  1. sudo apt-get install autocutsel

  2. add this line(autocutsel -fork) in: vi /home/b37399/.vnc/xstartup

    autocutsel -fork

like this

#!/bin/bash
xrdb $HOME/.Xresources
autocutsel -fork
startxfce4 &

restart vncserver