Come è possibile modificare il pool di applicazioni IIS seetings/properties programmatic (C#)? Ad esempio, come posso modificare l'impostazione "Abilita applicazioni a 32 bit"? Esistono riferimenti di proprietà per IIS 6 e IIS 7 su MSDN o Technet? Grazie in anticipo per il vostro aiuto!Pool di applicazioni IIS: modifica delle impostazioni programmatiche
5
A
risposta
1
Prova this per dimensioni.
DirectoryEntry root = this.GetDirectoryEntry("IIS://" + this.DomainName + "/W3SVC/AppPools");
if (root == null)
return null;
List<ApplicationPool> Pools = new List<ApplicationPool>();
...
7
È possibile risolvere il problema utilizzando appcmd.exe. Dove "DefaultAppPool" è il nome del pool.
appcmd list apppool /xml "DefaultAppPool" | appcmd set apppool /in /enable32BitAppOnWin64:true
Se avete problemi con l'esecuzione utilizzando C# un'occhiata How To: Execute command line in C#.
ps: Ulteriori informazioni su appcmd.exe è possibile trovare here. La posizione di default dello strumento è c: \ windows \ system32 \ inetsrv
0
una soluzione più facile che ha funzionato per me
ServerManager server = new ServerManager();
ApplicationPoolCollection applicationPools = server.ApplicationPools;
//this is my object where I put default settings I need,
//not necessary but better approach
DefaultApplicationPoolSettings defaultSettings = new DefaultApplicationPoolSettings();
foreach (ApplicationPool pool in applicationPools)
{
try
{
if (pool.Name == <Your pool name here>)
{
pool.ManagedPipelineMode = defaultSettings.managedPipelineMode;
pool.ManagedRuntimeVersion = defaultSettings.managedRuntimeVersion;
pool.Enable32BitAppOnWin64 = defaultSettings.enable32BitApplications;
pool.ProcessModel.IdentityType = defaultSettings.IdentityType;
pool.ProcessModel.LoadUserProfile = defaultSettings.loadUserProfile;
//Do not forget to commit changes
server.CommitChanges();
}
}
catch (Exception ex)
{
// log
}
}
e il mio oggetto, ad esempio ai fini
public class DefaultApplicationPoolSettings
{
public DefaultApplicationPoolSettings()
{
managedPipelineMode = ManagedPipelineMode.Integrated;
managedRuntimeVersion = "v4.0";
enable32BitApplications = true;
IdentityType = ProcessModelIdentityType.LocalSystem;
loadUserProfile = true;
}
public ManagedPipelineMode managedPipelineMode { get; set; }
public string managedRuntimeVersion { get; set; }
public bool enable32BitApplications { get; set; }
public ProcessModelIdentityType IdentityType { get; set;}
public bool loadUserProfile { get; set; }
}
Chi pensava si potrebbe usare tubazioni !? Grazie, è grandioso. – Rory