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

MOHAMED JACKARIAHPosted Jul 2, 2015, 10:39 AM
midhun bPosted Nov 15, 2013, 8:14 AM
Manikavelu VelayuthamPosted Nov 14, 2013, 7:03 AM
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 bPosted Nov 14, 2013, 6:51 AM
Manikavelu VelayuthamPosted Nov 14, 2013, 6:33 AM
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.
midhun bPosted Nov 14, 2013, 6:29 AM
Manikavelu VelayuthamPosted Nov 14, 2013, 6:02 AM
Does the IIS Metabase & Compatiblity is installed in that server / machine ? (This is mandatory, if this is not installed and it wont work.