使用的DirectoryEntry枚举IIS配置数据,获取收到COMException [英] Using DirectoryEntry to Enumerate IIS Configuration Data, Getting COMException
问题描述
我试图6服务器编程管理一组远程IIS的,但我遇到了一堵墙。
I'm attempting to manage a set of remote IIS 6 server programmatically, but am running into a wall.
我的客户端是Windows 7,我有域名。管理员权限
My client is Windows 7, and I have Domain Admin rights.
相关的代码如下:
public void Run()
{
DirectoryEntry W3SVC = new DirectoryEntry("IIS://server/w3svc");
foreach (DirectoryEntry site in W3SVC.Children)
{
Console.WriteLine(site.Name);
}
}
当我执行,我收到以下异常:
When I execute, I receive the following exception:
Unhandled Exception: System.Runtime.InteropServices.COMException: Unknown error (0x80005000)
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_IsContainer()
at System.DirectoryServices.DirectoryEntries.ChildEnumerator..ctor(DirectoryEntry container)
at System.DirectoryServices.DirectoryEntries.GetEnumerator()
at Worker.Worker.Run() in c:\code\Worker\Worker\Worker.cs:line 31
at Worker.Worker.Main(String[] args) in c:\code\Worker\Worker\Worker.cs:line 15
我看到,这是在绑定
(我假设是连接尝试)发生的事情,但我无法得到任何进一步的信息在这里。
I see that this is happening at Bind
(which I assume is the connection attempt), but am unable to get any further info here.
有没有人有意见?谢谢!
Does anyone have advice? Thanks!
推荐答案
啊!事实证明,我没有安装在我的机器上的IIS 6管理工具。一旦我安装的话,这个执行符合市场预期。
Ah! It turns out that I did not have the IIS 6 management tools installed on my machine. Once I installed them, this executed as expected.
这篇关于使用的DirectoryEntry枚举IIS配置数据,获取收到COMException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!