2010-01-28 12 views
5

¿Cómo puedo cambiar IIS seetings grupo de aplicaciones/propiedades de programación (C#)? Por ejemplo, ¿cómo puedo cambiar la configuración "Habilitar aplicaciones de 32 bits"? ¿Hay referencias de propiedad para IIS 6 e IIS 7 en MSDN o Technet? ¡Gracias de antemano por su ayuda!aplicaciones IIS: cambiar los ajustes programáticos

Respuesta

1

Trate this en el tamaño.

DirectoryEntry root = this.GetDirectoryEntry("IIS://" + this.DomainName + "/W3SVC/AppPools"); 
    if (root == null) 
     return null; 

List<ApplicationPool> Pools = new List<ApplicationPool>(); 
... 
7

Puede resolver el problema usando appcmd.exe. Donde "DefaultAppPool" es el nombre del grupo.

appcmd list apppool /xml "DefaultAppPool" | appcmd set apppool /in /enable32BitAppOnWin64:true 

Si tienes algún problema con ejecutarlo usando C# echar un vistazo How To: Execute command line in C#.

ps: Información adicional sobre appcmd.exe puede encontrar here. ubicación predeterminada de la herramienta es C: \ windows \ system32 \ inetsrv

+1

¿Quién sabía que se podía utilizar tuberías ! Gracias, esto es genial. – Rory

0

Una solución más fácil que trabajó para mí

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 
      } 
     } 

y mi objeto, por ejemplo, con fines

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; } 
} 
Cuestiones relacionadas