创建使用 .NET 4.0 的应用程序池
我使用以下代码创建应用程序池:
var metabasePath = string.Format(@"IIS://{0}/W3SVC/AppPools", serverName);
DirectoryEntry newpool;
DirectoryEntry apppools = new DirectoryEntry(metabasePath);
newpool = apppools.Children.Add(appPoolName, "IIsApplicationPool");
newpool.CommitChanges();
如何指定应用程序池应使用 .NET Framework 4.0?
I use the following code to create a app pool:
var metabasePath = string.Format(@"IIS://{0}/W3SVC/AppPools", serverName);
DirectoryEntry newpool;
DirectoryEntry apppools = new DirectoryEntry(metabasePath);
newpool = apppools.Children.Add(appPoolName, "IIsApplicationPool");
newpool.CommitChanges();
How do I specify that the app pool should use .NET Framework 4.0?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
其他答案在您的特定场景中更好,但一般请记住,您可以使用 appcmd 工具来执行此操作:https://technet.microsoft.com/en-us/library/cc731784%28v=ws.10%29.aspx。具体来说:
appcmd add apppool /name: string /managedRuntimeVersion: string /managementPipelineMode: Integrated |经典
The other answers are better in your particular scenario, but in general keep in mind that you can use the appcmd tool to do this: https://technet.microsoft.com/en-us/library/cc731784%28v=ws.10%29.aspx. Specifically:
appcmd add apppool /name: string /managedRuntimeVersion: string /managedPipelineMode: Integrated | Classic
将执行与 Microsoft.Web.Administration.dll 相同的操作,但使用 DirectoryEntry
还将
使用 DirectoryEntry 切换到集成或经典管道模式。
Will do the same thing as the Microsoft.Web.Administration.dll but using DirectoryEntry
Also
Will switch to integrated or classic pipeline mode using DirectoryEntry.
我从标签中看到您正在使用 IIS7。除非绝对必要,否则不要使用 IIS6 兼容组件。您的首选方法应该是使用
Microsoft.Web.Administration
托管 API。要使用此创建应用程序池并将 .NET Framework 版本设置为 4.0,请执行以下操作:
您应该添加对
Microsoft.Web.Administration.dll
的引用,该引用可在以下位置找到:I see from the tags you're using IIS7. Unless you absolutely have to, don't use the IIS6 compatibility components. Your preferred approach should be to use the
Microsoft.Web.Administration
managed API.To create an application pool using this and set the .NET Framework version to 4.0, do this:
You should add a reference to
Microsoft.Web.Administration.dll
which can be found in: