Legt einen neuen ApplikationPool an. Auf 64bit Systemen ermöglicht es die Ausführung von 32-bit APplikationen
/// <summary>
/// Updated or creates the application pool for classic .net 4.
/// </summary>
/// <param name = "poolName">Name of the pool.</param>
public void SetPool(string poolName)
{
using (var w3svc = new DirectoryEntry("IIS://localhost/W3SVC/AppPools"))
{
w3svc.RefreshCache();
//if you want to assign existing application pool, get that
Trace.WriteLine("getting app pool");
var appPool = w3svc.Children.OfType<DirectoryEntry>().FirstOrDefault(child => poolName.Equals(child.Name, StringComparison.OrdinalIgnoreCase))
?? w3svc.Children.Add(poolName, "IIsApplicationPool");
if (Environment.Is64BitOperatingSystem)
appPool.InvokeSet("Enable32BitAppOnWin64", true);
appPool.InvokeSet("AppPoolIdentityType", 2);
appPool.InvokeSet("AppPoolState", 2);
appPool.InvokeSet("Win32Error", 0);
appPool.InvokeSet("AppPoolCommand", 1);
appPool.CommitChanges();
}
}
Kommentare zum Snippet