internal RdpClient(ContainerControl parent, Size size, EventHandler resizeHandler) { this.parent = parent; this.size = size; try { rdpClient = new MsRdpClient9(); RDPConfigure(size); //add event handler for when RDP display is resized rdpClient.OnRemoteDesktopSizeChange += rdpClient_OnRemoteDesktopSizeChange; rdpClient.Resize += resizeHandler; // CA-96135: Try adding rdpControl to parent.Controls list; this will throw exception when // MsRdpClient9 control cannot be created (there is no appropriate version of dll present) parent.Controls.Add(rdpClient); allowDisplayUpdate = true; } catch (Exception ex) { if (parent.Controls.Contains(rdpClient)) { parent.Controls.Remove(rdpClient); } rdpClient.Dispose(); rdpClient = null; Log.Error("Adding rdpControl to parent.Controls list caused an exception.", ex); } }
public void Connect(string rdpIP) { try { RDPSetSettings(); } catch (Exception ex) { if (parent.Controls.Contains(rdpClient)) { parent.Controls.Remove(rdpClient); } rdpClient.Dispose(); rdpClient = null; Log.Error("Setting the RDP client properties caused an exception.", ex); } RDPConnect(rdpIP, size.Width, size.Height); }