使用下面的C#代码:当使用Microsoft.Web.Administration时,为什么我无法为FTP站点获取Site.State?
using System;
using Microsoft.Web.Administration;
namespace getftpstate
{
class Program
{
static void Main(string[] args)
{
ServerManager manager = new ServerManager();
foreach (Site site in manager.Sites)
{
Console.WriteLine("name: " + site.Name);
Console.WriteLine("state: " + site.State);
Console.WriteLine("----");
}
}
}
}
我得到以下输出:
C:\projects\testiisftp\getftpstate\getftpstate\bin\Debug>getftpstate.exe
name: Default Web Site
state: Stopped
----
name: Default FTP Site
Unhandled Exception: System.Runtime.InteropServices.COMException (0x800710D8): T
he object identifier does not represent a valid object. (Exception from HRESULT:
0x800710D8)
at Microsoft.Web.Administration.Interop.IAppHostProperty.get_Value()
at Microsoft.Web.Administration.ConfigurationElement.GetPropertyValue(IAppHos
tProperty property)
at Microsoft.Web.Administration.Site.get_State()
at getftpstate.Program.Main(String[] args) in C:\projects\testiisftp\getftpst
ate\getftpstate\Program.cs:line 17
任何想法,为什么我可能会看到上述0x800710D8 COM的错误?我可以使用IIS管理器来管理FTP站点(我可以启动,停止,更改设置等)。
我试图使用WMI作为一个变通,但你猜怎么着,FTP站点在IIS元数据库(当访问通过WMI)的W3SVC节点下存储,并且该网站的对于FTP站点,ServerState始终返回4,这意味着根据文档“已停止”(即使它在IIS管理器中显示为已启动)。 http://msdn.microsoft.com/en-us/library/ms524905(v=VS.90).aspx – 2010-06-09 12:21:14
此外,我已经提出了MS连接(请upvote,如果这会影响你):https://连接.microsoft.com/WindowsServerFeedback /反馈/信息/ 566045 /收到COMException-时,访问站点状态换一个-FTP站点,使用微软的Web的管理 – 2010-06-09 12:29:48
只是试图启动,并通过双方停止FTP站点MWA和WMI;都没有工作,有类似的结果。但是,WMI并没有默默地做任何事情,而不是抛出异常。 – 2010-06-09 13:01:17