3

I am writing a WPF UserControl that hosts a RemoteApp session using the AxMSTSCLib library. I'm using the information from this SO question. The code I wrote is very close to the answer of that question.

I placed the RemoteApp ActiveX (axMsRdpClient9NotSafeForScripting1) inside my WPF UserControl, and provide the necessary parameters when connecting.

But the problem is that the WPF Window that contains the UserControl opens but is blank. The RemoteApp actually launches but in a separate window, outside the main WPF Window. How can I ensure the remote app opens inside the WPF UserControl? What am I missing?

Here is my code:

public void Connect()
    {
        try
        {
            axMsRdpClient9NotSafeForScripting1.UserName = @"domain\username";
            axMsRdpClient9NotSafeForScripting1.Domain = "GTCS";
            axMsRdpClient9NotSafeForScripting1.AdvancedSettings7.ClearTextPassword = "password";
            axMsRdpClient9NotSafeForScripting1.AdvancedSettings9.AuthenticationLevel = 2;
            axMsRdpClient9NotSafeForScripting1.AdvancedSettings9.EnableCredSspSupport = true;
            axMsRdpClient9NotSafeForScripting1.AdvancedSettings9.NegotiateSecurityLayer = false;
            axMsRdpClient9NotSafeForScripting1.AdvancedSettings9.RDPPort = 3389;
            axMsRdpClient9NotSafeForScripting1.Server = "GT-DZ1-ATLS.GTCS.LOCAL"; // 10.24.141.199
            axMsRdpClient9NotSafeForScripting1.RemoteProgram2.RemoteProgramMode = true;

            axMsRdpClient9NotSafeForScripting1.OnConnected += (o, e) =>
            {
                m_connectionState = axMsRdpClient9NotSafeForScripting1.Connected;
                ((ITSRemoteProgram)((IMsRdpClient9)axMsRdpClient9NotSafeForScripting1.GetOcx()).RemoteProgram).ServerStartProgram(@"||startchrome", "", "", true, "", false);
                //axMsRdpClient9NotSafeForScripting1.RemoteProgram.ServerStartProgram(@"||startchrome", "", "", true, "", false);
            };

            axMsRdpClient9NotSafeForScripting1.AdvancedSettings7.PublicMode = false;
            axMsRdpClient9NotSafeForScripting1.DesktopWidth = SystemInformation.VirtualScreen.Width;
            axMsRdpClient9NotSafeForScripting1.DesktopHeight = SystemInformation.VirtualScreen.Height;
            axMsRdpClient9NotSafeForScripting1.AdvancedSettings9.SmartSizing = true;
            IMsTscNonScriptable secured = (IMsTscNonScriptable)axMsRdpClient9NotSafeForScripting1.GetOcx();
            secured.ClearTextPassword = "password";
            axMsRdpClient9NotSafeForScripting1.AdvancedSettings7.ClearTextPassword = "password";

            axMsRdpClient9NotSafeForScripting1.AdvancedSettings9.RedirectClipboard = true;
            axMsRdpClient9NotSafeForScripting1.AdvancedSettings9.RedirectPrinters = true;
            axMsRdpClient9NotSafeForScripting1.AdvancedSettings9.RedirectPorts = false;
            axMsRdpClient9NotSafeForScripting1.AdvancedSettings9.RedirectSmartCards = true;
            axMsRdpClient9NotSafeForScripting1.AdvancedSettings9.RedirectDrives = true;
axMsRdpClient9NotSafeForScripting1.Visible = true;
            axMsRdpClient9NotSafeForScripting1.Enabled = true;
            axMsRdpClient9NotSafeForScripting1.Connect();
            m_connectionState = axMsRdpClient9NotSafeForScripting1.Connected;
        }
        catch (Exception ex)
        {
            var err = ex.Message;
            MessageBox.Show(ex.Message);
        }
Ray
  • 4,019
  • 7
  • 33
  • 82

0 Answers0