Je suis en train de configurer mon IIS suivant programme les étapes de cette msdn guideC#: essayer de définir « ServerBindings » propriété de mon site programatically, continue à se briser
la seule différence que j'ai fait commutait à WinForms au lieu de la console .. et variables à la place des paramètres de fonction.
cependant le code lance une exception lorsque je tente de définir la valeur de singleproperty ...
voici mon code ..
string metabasePath = "IIS://localhost/W3SVC/1234", propertyName = "ServerBindings";
object newValue = " :8080:";
try
{
DirectoryEntry path = new DirectoryEntry(metabasePath);
//when i try to retrieve the old value,it returns a null
PropertyValueCollection propValues = path.Properties[propertyName];
MessageBox.Show("7");
//the code throws an exception after messagebox,
//kinda old school debuging
path.Properties[propertyName][0] = newValue;
path.CommitChanges();
lblerror.Text = "Done";
}
catch (Exception ex)
{
if ("HRESULT 0x80005006" == ex.Message)
lblerror.Text = " Property does not exist at ";
else
lblerror.Text = "Failed in SetSingleProperty "+ ex.Message.ToString();
}