0

Am unable to get the connection done for the remote desktop using WPF.

Following is the code:

private void EmbedRdp()
        {
            // Create a new instance of the ActiveX control
            AxMsRdpClient6NotSafeForScripting rdpControl = new AxMsRdpClient6NotSafeForScripting();
            rdpControl.CreateControl();

            rdpControl.Server = "";
            rdpControl.UserName = "";
            rdpControl.AdvancedSettings2.ClearTextPassword = "";
            rdpControl.AdvancedSettings7.EnableCredSspSupport = true;

            rdpControl.ColorDepth = 16;
            rdpControl.DesktopWidth = 1024;
            rdpControl.DesktopHeight = 720;
            
            rdpControl.Connect();

            // Add the control to a WindowsFormsHost control
            WindowsFormsHost host = new WindowsFormsHost();
            host.Child = rdpControl;

            RDPContainer.Children.Add(host);
        }

The connection somehow is never getting through.

I tried subscribing to different events like OnConnected, OnFatalError, OnConnecting, and OnLogonError, None of these events are triggered.

Similar code works with WinForms though.

Not sure what am missing here.

Thanks in Advance.

  • What exactly is `AxMsRdpClient6NotSafeForScripting`? There is the Microsoft class `MsRdpClient6NotSafeForScripting` but not that. Perhaps its documentation might shed some light – Joe Apr 15 '23 at 16:58
  • Similar behavior with MsRdpClient6NotSafeForScripting too. This is Active X Control. Took from https://stackoverflow.com/questions/3632872/how-to-host-a-terminal-session-mstsc-in-a-wpf-applicaiton/3696597#3696597 – Praneeth Kumar Gunda Apr 16 '23 at 01:49