2010-01-28 27 views
5

Làm cách nào để thay đổi các thuộc tính/thuộc tính của pool ứng dụng IIS (C#)? Ví dụ: làm thế nào tôi có thể thay đổi cài đặt "Bật ứng dụng 32 bit"? Có tham chiếu thuộc tính nào cho IIS 6 và IIS 7 trên MSDN hoặc Technet không? Cảm ơn trước sự giúp đỡ của bạn!Hồ bơi ứng dụng IIS: thay đổi cài đặt có lập trình

Trả lời

1

Hãy thử this để biết kích thước.

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

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

Bạn có thể giải quyết sự cố bằng cách sử dụng appcmd.exe. Trong đó "DefaultAppPool" là tên của nhóm.

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

Nếu bạn gặp khó khăn khi chạy nó bằng C# hãy xem How To: Execute command line in C#.

ps: Thông tin bổ sung về appcmd.exe bạn có thể tìm thấy here. Mặc định vị trí của công cụ này là C: \ windows \ system32 \ inetsrv

+1

Ai biết bạn có thể sử dụng đường ống !? Cảm ơn, điều này thật tuyệt. – Rory

0

Một giải pháp dễ dàng hơn mà làm việc cho tôi

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

và đối tượng của tôi ví dụ mục đích

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; } 
} 
Các vấn đề liên quan