我在 MSDN 论坛上搜索了这个,但似乎每个人(我认为)都建议恢复到 RDP 7.x(卸载 MS 更新 KB2592687)。
我有一个用 C#/WPF 编写的自定义远程桌面客户端,远程桌面 ActiveX 控件托管在 WindowsFormsHost 控件中。 该应用在更新 RDP 8.0(MS 更新 KB2592687)之前运行良好。如果我卸载 MS 更新(恢复到 RDP 7.1),该应用程序可以运行。
我的 RDP 客户端用于连接到 Virtualbox VRDP (Virtualbox 4.2.x),不需要身份验证(Null)。安装 RDP 8.0 后,Windows 远程桌面客户端 (mstsc.exe) 连接正常,响应速度更好(RDP 8.0 增强功能);但我的自定义 RD 客户端无法连接。
经进一步调查,我的自定义 RDP 客户端没有抛出任何异常或触发 OnConnecting 和 OnLogonError 或大多数其他事件。 奇怪的是,它只触发这两个事件(按顺序)
OnAuthenticationWarningDisplayed
OnAuthenticationWarningDismissed
我还使用 RawCap( http://www.netresec.com/?page=RawCap ) 进行了测试,以查看我的自定义 RDP 客户端是否在这些事件之前将数据包发送到 Virtualbox VRDP。令人惊讶的是,它甚至不发送数据包。 (MS RD 客户端 - mstsc.exe 工作正常。)
所以它归结为我的自定义 RDP 客户端上的这些事件/方法调用,不幸的是我被卡住了。
(为简洁起见缩短了代码)
AxMSTSCLib.AxMsRdpClient8 rdp = new AxMSTSCLib.AxMsRdpClient8();
rdp.OnAuthenticationWarningDisplayed+=new EventHandler(rdp_OnAuthenticationWarningDisplayed);
rdp.OnAuthenticationWarningDismissed+=new EventHandler(rdp_OnAuthenticationWarningDismissed);
rdp.Server = server;
rdp.AdvancedSettings8.RDPPort = 5050;
//No username/password since Virtualbox RDP authentication is set to *null*
//MS RD Client connects just fine to Virtualbox RDP without username/password
try
{
rdp.Connect();
}
catch (Exception ex)
{
}
在 OnAuthenticationWarningDisplayed 和 OnAuthenticationWarningDismissed 上设置断点可确认这两个事件均在 Connect() 方法后触发。 我怀疑 ActiveX 控件在调用 Connect() 方法后试图显示一个对话框(??);但我似乎无法弄清楚。
是否有人使用 RDP 8.0 完成了一些自定义客户端?让它工作的先决条件是什么(代码)。
非常感谢!将不胜感激。
最佳答案
解决了这个问题!
只需尝试使用 AxMSTSCLib.AxMsRdpClient8NotSafeForScripting 而不是 AxMSTSCLib.AxMsRdpClient8
这是工作代码(Delphi):
rdp:TMsRdpClient8NotSafeForScripting; // ***Instead of TMsRdpClient8 (!!!)***
...
if rdp.Connected<>0 then rdp.Disconnect;
rdp.Server:='192.168.1.1';
rdp.UserName:='User';
rdp.AdvancedSettings8.ClearTextPassword:='Password';
rdp.AdvancedSettings8.AuthenticationLevel:=2;
rdp.AdvancedSettings8.EnableCredSspSupport:=true;
rdp.AdvancedSettings8.NegotiateSecurityLayer:=false;
rdp.AdvancedSettings8.RelativeMouseMode:=true;
rdp.AdvancedSettings.BitmapPeristence:=1;
rdp.AdvancedSettings.Compress:=1;
rdp.AdvancedSettings8.SmartSizing:=true;
rdp.DesktopHeight:= Screen.Height;
rdp.DesktopWidth:= Screen.Width;
rdp.FullScreen:=true;
rdp.ColorDepth:= 15;
rdp.AdvancedSettings8.RedirectDrives:=false;
rdp.AdvancedSettings8.RedirectPrinters:=false;
rdp.AdvancedSettings8.RedirectClipboard:=true;
rdp.AdvancedSettings8.RedirectSmartCards:=false;
rdp.Connect;
附言并且不要使用以下属性:
rdp.AdvancedSettings8.AuthenticationServiceClass
关于使用 RDP 8.0 的 C# 自定义远程桌面客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19869076/