Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# RDP客户端循环_C#_.net_Winforms - Fatal编程技术网

C# RDP客户端循环

C# RDP客户端循环,c#,.net,winforms,C#,.net,Winforms,此标准要求非常有效: private void RDP(string pass) { try { rdp.Server = TBIP.Text; rdp.UserName = TBUserName.Text; IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp.GetOcx(); secured.ClearTextPassword = pass;

此标准要求非常有效:

private void RDP(string pass)
{
    try
    {
        rdp.Server = TBIP.Text;
        rdp.UserName = TBUserName.Text;
        IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp.GetOcx();
        secured.ClearTextPassword = pass;
        rdp.Connect();
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex);
    }
}
我怎样才能做一个循环。例如,此示例不起作用:

RDP("123");
它在第59行抛出一个错误

foreach (var p in pwd)
{
    RDP(p);
    Thread.Sleep(30 * 1000);
    rdp.Disconnect();
    rdp.AllowDrop = true;
}
“异常输出”


我可以重复你的错误,但我不能广泛使用RDP进行测试,但也许可以帮助你

想分享错误信息吗?还是猜游戏?“不工作”意味着你会出错,对吗?什么错误?
rdp.Server = TBIP.Text;
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in AxInterop.MSTSCLib.dll
System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
   at MSTSCLib.IMsRdpClient8.set_Server(String pServer)
   at AxMSTSCLib.AxMsRdpClient8.set_Server(String value)
   at RDP.Form1.RDP() in c:\Users\x\Documents\Visual Studio 2012\Projects\RDP\RDP\Form1.cs:line 59