2010-01-28 24 views

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

+1

Chi pensava si potrebbe usare tubazioni !? Grazie, è grandioso. – Rory

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; } 
} 
Problemi correlati