utilizzando il seguente codice C#:Perché non riesco a ottenere Site.State per un sito FTP quando si utilizza Microsoft.Web.Administration?
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("----");
}
}
}
}
ottengo il seguente output:
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
Tutte le idee perché potrei essere vedendo quanto sopra errore 0x800710D8 COM? Sono in grado di gestire il sito FTP con il gestore IIS (posso avviare, fermare, modificare le impostazioni, ecc.).
Ho cercato di utilizzare WMI come un lavoro in giro, ma indovinate un po ', siti FTP vengono archiviati sotto il nodo W3SVC nella metabase di IIS (quando l'accesso tramite WMI), e il sito di ServerState restituisce sempre 4 per siti FTP, che significa "Interrotto" in base alla documentazione (anche se viene visualizzato come Avviato in Gestione IIS). http://msdn.microsoft.com/en-us/library/ms524905(v=VS.90).aspx –
Inoltre, ho sollevato questo su MS connect (per favore upvote se questo ti colpisce): https: // connect .microsoft.com/WindowsServerFeedback/feedback/dettagli/566045/comexception-when-accessing-site-state-per-un-ftp-site-using-microsoft-web-administration –
Ho appena provato ad avviare e interrompere il sito FTP tramite entrambi MWA e WMI; né ha funzionato, con risultati simili. Tuttavia, invece di lanciare un'eccezione, WMI non fa nulla in silenzio. –