[VNCSharp帮助]客户端立即断开连接 [英] [VNCSharp Help] Client Disconnecting Immediately
问题描述
大家好,
我知道,这不是问这个问题的最佳地点,但是我找不到专门的地方 VNCSharp 支持社区. p>
我创建了一个使用该控件的WPF应用程序,方法是将其包装在WindowsFormsHost标记中,并能够使其几乎连接起来.但是就像客户端应该连接到服务器一样,它也会断开连接!使用常规的VNC客户端(RealVNC, 客户端和服务器),我可以轻松连接.
我的代码现在非常简单,我只是在程序加载后发送一个连接:
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("... snip ..."); } catch (VncProtocolException vex) { MessageBox.Show(this, string.Format("Unable to connect to VNC host:\n\n{0}.\n\nCheck that a VNC host is running there.", vex.Message), string.Format("Unable to Connect to {0}", _remoteDesktop), MessageBoxButton.OK, MessageBoxImage.Exclamation); } catch (Exception ex) { MessageBox.Show(this, string.Format("Unable to connect to host. Error was: {0}", ex.Message), string.Format("Unable to Connect to {0}", _remoteDesktop), MessageBoxButton.OK, MessageBoxImage.Exclamation); } } void RemoteDesktop_ConnectionLost(object sender, EventArgs e) { MessageBox.Show(this, "Lost Connection to Host.", "Connection Lost", MessageBoxButton.OK, MessageBoxImage.Information); } void RemoteDesktop_ConnectComplete(object sender, ConnectEventArgs e) { // Update the Form to match the geometry of remote desktop (including the height of the menu bar in this form). this.Width = e.DesktopWidth; this.Height = e.DesktopHeight; // Change the Form's title to match the remote desktop name //Text = e.DesktopName; //FlipMenuOptions(); // Give the remote desktop focus now that it's connected //RemoteDesktop.Focus(); } private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { //_remoteDesktop.Disconnect(); } } }
邪恶,
很抱歉,我没有使用VNCSharp的经验.
>但是就像客户端应该连接到服务器一样,它也会断开连接!您在上面的句子中是什么意思?您能更清楚地解释一下吗?
谢谢,
刘琳达MSDN用户支持在论坛中
如果您对我们的支持有任何反馈,请联系 msdnmg@microsoft.com
Hello all,
This isn't the best place to ask this question, I know, but I can't find a dedicated VNCSharp support community.
I have created a WPF application that uses the control, by wrapping it in a WindowsFormsHost tag, and am able to get it to almost connect. But just as the client should connect to the server it disconnects! Using the regular VNC client (RealVNC, client and server) I'm able to connect without any trouble.
My code is pretty simple right now, I'm just sending a connection after the program loads:
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("... snip ..."); } catch (VncProtocolException vex) { MessageBox.Show(this, string.Format("Unable to connect to VNC host:\n\n{0}.\n\nCheck that a VNC host is running there.", vex.Message), string.Format("Unable to Connect to {0}", _remoteDesktop), MessageBoxButton.OK, MessageBoxImage.Exclamation); } catch (Exception ex) { MessageBox.Show(this, string.Format("Unable to connect to host. Error was: {0}", ex.Message), string.Format("Unable to Connect to {0}", _remoteDesktop), MessageBoxButton.OK, MessageBoxImage.Exclamation); } } void RemoteDesktop_ConnectionLost(object sender, EventArgs e) { MessageBox.Show(this, "Lost Connection to Host.", "Connection Lost", MessageBoxButton.OK, MessageBoxImage.Information); } void RemoteDesktop_ConnectComplete(object sender, ConnectEventArgs e) { // Update the Form to match the geometry of remote desktop (including the height of the menu bar in this form). this.Width = e.DesktopWidth; this.Height = e.DesktopHeight; // Change the Form's title to match the remote desktop name //Text = e.DesktopName; //FlipMenuOptions(); // Give the remote desktop focus now that it's connected //RemoteDesktop.Focus(); } private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { //_remoteDesktop.Disconnect(); } } }
Hi Evil,
Sorry that I have not experience with VNCSharp.
> But just as the client should connect to the server it disconnects!What do you mean in the above sentence? Could you explain it more clearly?
Thanks,
Linda LiuMSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
这篇关于[VNCSharp帮助]客户端立即断开连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!