TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
midhun b
NA
20
27.7k
Programatically recycle Remote IIS server application pools
Nov 14 2013 5:08 AM
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
Reply
Answers (
7
)
Split function in vb.net
IP address