Hamed
Hamed

Reputation: 1213

Clipboard operations fail using Tight VNC

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.

Upvotes: 1

Views: 2928

Answers (2)

Sashus
Sashus

Reputation: 421

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);
   }

Upvotes: 0

ashish
ashish

Reputation: 377

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

Upvotes: 1

Related Questions