DirectoryEntry de = new DirectoryEntry(@"IIS://" + this.MachineName + @"/W3SVC", this.LoginAccount, this.LoginPassword);当this.MachineName为本机即localhost的时候能够正常连接。当this.MachineName为远程机器的IP时,若账号密码错误,就报:拒绝访问。这个没问题。但是当账号密码正确的时候,就报:RPC 服务器不可用。有没有哪位大神碰到过并解决过这个问题的啊?PS:远程机器的RPC服务已开启小弟在此先谢过各位了!

解决方案 »

  1.   

    先不要通过程序,直接在网上邻居中看看能不能打开这个目录,如果打不开共享,防火墙都看一下如果再不行,RPC(Remote Procedure Call Protocol)——远程过程调用协议
    看看远程的这个协议有没有
      

  2.   

            static void Main(string[] args)
            {
                string MachineName = "127.0.0.1";            string LoginAccount = "username";            string LoginPassword = "password";            DirectoryEntry rootDirectory = new DirectoryEntry(@"IIS://" + MachineName + @"/W3SVC", LoginAccount, LoginPassword);
                int totalServerCount = 0;
                try
                {                foreach (DirectoryEntry child in rootDirectory.Children)
                    {
                        if (child.SchemaClassName == "IIsWebServer")
                        {
                            totalServerCount++;
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw (new Exception("Can't connect to IIS Server " + MachineName + " : " + ex.Message));
                }            Console.WriteLine(totalServerCount);这是一段控制台测试程序,放入Program.cs的main方法中即可,需要引入System.DirectoryServices;
      

  3.   

    防火墙关了还是不行,RPC已经开启了的