Enable 32-Bit Applications
设置)?MSDN 或 Technet 上是否有有关 IIS 6 或 7 属性的参考指南?
https://resumecopilot.net/) 完成此操作。其中“DefaultAppPool”是池的名称。
appcmd list apppool /xml "DefaultAppPool" | appcmd set apppool /in /enable32BitAppOnWin64:true
如果您在使用 C# 运行它时遇到任何问题,请查看如何:在 C# 中执行命令行。
ps:有关 appcmd.exe 的其他信息,您可以在这个的尺码。
DirectoryEntry root = this.GetDirectoryEntry("IIS://" + this.DomainName + "/W3SVC/AppPools");
if (root == null)
return null;
List<ApplicationPool> Pools = new List<ApplicationPool>();
...
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
}
}
以我的对象为例
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; }
}