在 Vista 和 Vista 上启动网站时出现问题通过 .NET 的 IIS 7
我需要通过 C# 以编程方式获取 IIS 网站状态。我通常这样做:
DirectoryEntry DE = new DirectoryEntry( string.Format( "IIS://localhost/W3SVC/{0}", siteID ) );
Int32 serverState = (Int32)DE.Properties["ServerState"][0];
if ( serverState == IISHelper.MD_SERVER_STATE_STOPPED )
DE.Invoke("Start", new object[] { });
但此代码在 Windows Vista 上不起作用,即使站点正在运行并且 DE.Invoke("Start", new object[] { }) 抛出互操作异常,serverState 始终为 4(已停止) 。
如何在 Vista 上执行此操作?
谢谢。
I need to get IIS web-site state programmatically via C#. I usually do it this way:
DirectoryEntry DE = new DirectoryEntry( string.Format( "IIS://localhost/W3SVC/{0}", siteID ) );
Int32 serverState = (Int32)DE.Properties["ServerState"][0];
if ( serverState == IISHelper.MD_SERVER_STATE_STOPPED )
DE.Invoke("Start", new object[] { });
But this code does't work on Windows Vista, serverState is always 4 (Stopped) even if the site is running and DE.Invoke("Start", new object[] { }) throws Interop exception.
How can i do this on Vista?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论