3

I am creating a windows application in C#. I have a form, added rdp control and trying to show VM in the form. I am using AxMSTSCLib.AxMsTscAxNotSafeForScripting to programmatically open a remote VM. The call to connect() executes without any error but VM is not showing up. Am I missing anything? Below is the code:

AxMSTSCLib.AxMsTscAxNotSafeForScripting rdpClient;

rdpClient.Server = "IP address";    

rdpClient.UserName = @"builtin\Username";

MSTSCLib.IMsTscNonScriptable secured = MSTSCLib.IMsTscNonScriptable)rdpClient.GetOcx();

secured.ClearTextPassword = "Password";

rdpClient.Visible = true;

rdpClient.Connect();

rdpClient.Show();

I expect to see the remote VM in the windows form.

slugmandrew
  • 1,776
  • 2
  • 25
  • 45
Jagadesh K
  • 31
  • 2
  • Mishaps are reported back through events, you didn't subscribe any. – Hans Passant Jun 12 '19 at 09:25
  • Thanks for the suggestion. I added events onConnecting, onConnected, onFatalError, onWarning, onLogonError. OnConnecting event got fired, completed without any error. But none of the other events were fired. Do you suggest any other events or troubleshooting steps? – Jagadesh K Jun 12 '19 at 10:01
  • Did you actually add the control to the form? The declaration of rdpClient suggests you didn't. – Hans Passant Jun 12 '19 at 10:06
  • I did, the actual declaration was private AxMSTSCLib.AxMsTscAxNotSafeForScripting rdpClient; Code from my initializecomponent looks like this.rdpClient = new AxMSTSCLib.AxMsTscAxNotSafeForScripting(); this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.rdpClient)).EndInit(); When I click on the connect button, onConnectingEvent is fired. So, I believe I have added control on the form correctly. Anyways, I will do a fresh form and let you know or may be share the project here. – Jagadesh K Jun 12 '19 at 13:37
  • I didn't find a way to attach my project here? Any suggestions? – Jagadesh K Jun 13 '19 at 19:03

0 Answers0