的WinForms的ActiveX RDP客户端发出带有NLA(WinForms ActiveX R

2019-10-21 14:38发布

我试图让使用RDP ActiveX控件作为一个学习锻炼的C#一个WinForms RDP客户端。 当目标服务器不使用网络级身份验证(NLA)我能得到的一切工作,但是当我尝试和配置控制使用“EnableCredSspSupport”,我认为这是需要NLA,通过运行时,我得到以下错误编码:

类型的未处理的异常“System.Windows.Forms.AxHost.InvalidActiveXStateException”发生在AxInterop.MSTSCLib.dll

该代码是:

        AxMsRdpClient9NotSafeForScripting rdp;

        rdp = new AxMsRdpClient9NotSafeForScripting();

        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));

        ((System.ComponentModel.ISupportInitialize)(rdp)).BeginInit();
        rdp.Dock = System.Windows.Forms.DockStyle.Fill;
        rdp.Enabled = true;
        rdp.Location = new System.Drawing.Point(0, 0);
        rdp.Name = "rdp";
        rdp.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("rdp.OcxState")));
        rdp.Size = new System.Drawing.Size(828, 687);
        rdp.TabIndex = 0;

        rdp.AdvancedSettings9.AuthenticationLevel = 2;
        rdp.AdvancedSettings9.EnableCredSspSupport = true;

        MainsplitContainer.Panel2.Controls.Add(rdp);

        ((System.ComponentModel.ISupportInitialize)(rdp)).EndInit();

        rdp.Server = "XXX.XXX.XXX.XXX";
        rdp.Connect();

很多这样的代码是从下列来源错位在一起,但学习的代码通常是站在巨人的肩膀上,右!?

http://msdn.microsoft.com/en-us/library/aa383022(VS.85).aspx https://searchcode.com/codesearch/view/3716390/

...和一对夫妇更多的来源,我没有共享的声誉(第一篇文章!)

任何见解在那里帮助我对我的方式?

谢谢!

.... Aaaand工作的代码:

            AxMSTSCLib.AxMsRdpClient8NotSafeForScripting _RDPClient;
        _RDPClient = new AxMSTSCLib.AxMsRdpClient8NotSafeForScripting();

        MainsplitContainer.Panel2.Controls.Add(_RDPClient);

        ((System.ComponentModel.ISupportInitialize)(_RDPClient)).BeginInit();
        _RDPClient.Dock = System.Windows.Forms.DockStyle.Fill;
        _RDPClient.Enabled = true;
        _RDPClient.Location = new System.Drawing.Point(0, 0);
        _RDPClient.Name = "axMsTscAxNotSafeForScripting1";
        _RDPClient.OcxState = ((System.Windows.Forms.AxHost.State)(_RDPClient.OcxState));
        _RDPClient.Size = new System.Drawing.Size(579, 608);
        _RDPClient.TabIndex = 0;
        _RDPClient.AdvancedSettings8.EnableCredSspSupport = true;
        ((System.ComponentModel.ISupportInitialize)(_RDPClient)).EndInit();

        _RDPClient.OnDisconnected += new IMsTscAxEvents_OnDisconnectedEventHandler(axMsTscAx_OnDisconnected);


        _RDPClient.Server = IP;
        _RDPClient.Connect();

Answer 1:

采用 :

CType(rdp, System.ComponentModel.ISupportInitialize).EndInit()
rdp.CreateControl()

寻找你相当于在C#



文章来源: WinForms ActiveX RDP Client Issue With NLA
标签: c# activex rdp