Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/328.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# 使用DirectoryEntry与IIS交互_C#_Iis_Com_Interop - Fatal编程技术网

C# 使用DirectoryEntry与IIS交互

C# 使用DirectoryEntry与IIS交互,c#,iis,com,interop,C#,Iis,Com,Interop,我正在使用下面的代码尝试连接到IIS string hostName = "server1" DirectoryEntry iis = new DirectoryEntry("IIS://" + hostname + "/w3svc"); foreach (DirectoryEntry node in iis.Children) // Getting exception on this line { // some stuff } 例外情况详细信息 System.Runtime.Inte

我正在使用下面的代码尝试连接到IIS

string hostName = "server1"
DirectoryEntry iis = new DirectoryEntry("IIS://" + hostname + "/w3svc");

foreach (DirectoryEntry node in iis.Children) // Getting exception on this line
{
  // some stuff
}
例外情况详细信息

System.Runtime.InteropServices.COMException (0x80070057): The parameter is incorrect.

我认为server1有一些问题,很可能是server1上的iis有问题,因为同样的代码在其他服务器上运行良好。只是不知道服务器1的问题出在哪里

停止。现在是使用Microsoft.Web.Administration的时候了。但我需要在远程计算机上执行此操作。不要认为网络管理可以做到这一点。谁告诉你它不能做到的?尝试