Note: Add Microsoft.Web.Management.dll as reference(This can be found Windows/system32/inetsrv folder)
1) Create a class structure to take input parameters for Creation of Application Pool
/// <summary>
/// This class just provides parameters for application pool creation.
/// </summary>
public class ApplicationPoolParams
{
public ApplicationPoolParams(string appPoolName,
string metabasePath,uint queueLength,string managedRuntimeVersion,ManagedPipelineMode managedPipeLineMode,ProcessModelAppPool processModel,RecyclingAppPool recycleAppPool,CpuAppPool cpuAppPool)
{
Name = appPoolName;MetabasePath = metabasePath;QueueLength = queueLength;ManagedRuntimeVersion = managedRuntimeVersion;PipelineMode = managedPipeLineMode;ProcessModelData = processModel;RecycleAppPoolData = recycleAppPool;CpuData = cpuAppPool;
}public string Name { get; set; }public string MetabasePath { get; set; }public uint QueueLength { get; set; }public string ManagedRuntimeVersion { get; set; }public ManagedPipelineMode PipelineMode { get; set; }public ProcessModelAppPool ProcessModelData { get; set;}public RecyclingAppPool RecycleAppPoolData { get; set; }public CpuAppPool CpuData { get; set; }}public class ProcessModelAppPool{
public ProcessModelAppPool(TimeSpan idleTimeOut,uint maxProcesses){IdleTimeout = idleTimeOut;MaxProcesses = maxProcesses;}
public TimeSpan IdleTimeout { get; set; }public uint MaxProcesses { get; set; }
}public class RecyclingAppPool{
public RecyclingAppPool(bool isOverlappingRotation,bool isRotationOnConfigChange, PeriodicRestartAppPool periodic){
DisallowOverlappingRotation = isOverlappingRotation;DisallowRotationOnConfigChange = isRotationOnConfigChange;
Read more: s.ghosh
QR: