Hi,
I have a requirement where i have to recycle Application pools preset on remote IIS server.
I have achieved all the requirement and working great but the only error i am getting at the recycle. Here is my code.
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;
}
}
}
}
Any One please help.
Thanks in advance
Midhun Bezawada
Loading


Manikavelu VelayuthamRank #413 · 6K reputationPosted Nov 14, 2013, 1:02 AM EST
Does the IIS Metabase & Compatiblity is installed in that server / machine ? (This is mandatory, if this is not installed and it wont work.
midhun b20 reputationPosted Nov 14, 2013, 1:29 AM EST
midhun b20 reputationPosted Nov 14, 2013, 1:51 AM EST
Manikavelu VelayuthamRank #413 · 6K reputationPosted Nov 14, 2013, 2:03 AM EST
Its an Permission Issue on your Application Pool.
You should impersonate with Administrator account or whoever has the access to that server.
http://forums.iis.net/t/1181404.aspx
OR
It might be due to the space in your application pool name. Just look into this link and fix your problem
http://technet.microsoft.com/en-us/library/cc770764(v=ws.10).aspx
midhun b20 reputationPosted Nov 15, 2013, 3:14 AM EST
MOHAMED JACKARIAH153 reputationPosted Jul 2, 2015, 6:39 AM EDT
Manikavelu VelayuthamRank #413 · 6K reputationPosted Nov 14, 2013, 1:33 AM EST
and check for the IIS 6 Management Compatiblity is installed or not.
If it is not installed, install it and then check with your code.