views:

38

answers:

1

I am using VNCSharp (http://cdot.senecac.on.ca/projects/vncsharp/) to create a WPF based VNC client.

When I try to connect to a server I am almost immediately disconnected. But when I use the RealVNC client (a RealVNC server is running) the connection completes just fine.

Does anyone have any ideas why I'm getting bounced off the server?

My XAML:

<Window x:Class="RemoteVirtualDesktop.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525"
    Loaded="Window_Loaded" Closing="Window_Closing">
    <Grid>
        <WindowsFormsHost Name="VncControlHost" />
    </Grid>
</Window>

My Source:

namespace RemoteVirtualDesktop
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        RemoteDesktop _remoteDesktop;

        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            _remoteDesktop = new RemoteDesktop();
            VncControlHost.Child = _remoteDesktop;

            _remoteDesktop.ConnectComplete += RemoteDesktop_ConnectComplete;
            _remoteDesktop.ConnectionLost += RemoteDesktop_ConnectionLost;

            try {
                _remoteDesktop.Connect("... snipped ...");
            }
            catch (VncProtocolException vex)
            {
                // ... snipped ...
            }
            catch (Exception ex)
            {
                // ... snipped ...
            }
        }

        void RemoteDesktop_ConnectionLost(object sender, EventArgs e)
        {
            // ... snipped ...
        }

        void RemoteDesktop_ConnectComplete(object sender, ConnectEventArgs e)
        {
            this.Width = e.DesktopWidth;
            this.Height = e.DesktopHeight;
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            //_remoteDesktop.Disconnect();
        }
    }
}