Click here to Skip to main content
15,882,464 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
System.DirectoryServices.DirectoryEntry Root = new DirectoryEntry("IIS://ServerName/W3SVC/AppPools", "Username", "password");

if (Root == null)
{
Console.Write("No Child in AppPool");
}
else
{

foreach (DirectoryEntry dir in Root.Children)
{
System.DirectoryServices.PropertyCollection pr = dir.Properties;
//AppPoolNameis an existing application pool in iis
if (dir.Name.Trim() == "AppPoolName")
{
DesiredAppPoolName = dir.Name;

using (DirectoryEntry appPoolEntry = new DirectoryEntry("IIS://Servername/W3SVC/AppPools/" + DesiredAppPoolName.Trim(), "username", "password"))
{


int status = (int)appPoolEntry.InvokeGet("AppPoolState");
//Status = 4 represents application pool is stopped
if (status != 4)
{
//This Line is giving me exception Unknown name exception
appPoolEntry.Invoke("Recycle");

}
appPoolEntry.Dispose();
}

break;

}

}

}
}
Note that iam to get status of remote IIS application pool it is only that i am unable to recycle

Can Anyone Help me

Thanks in advance

Midhun Bezawada
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900