创建使用.NET 4.0的应用程序池 [英] Create an application pool that uses .NET 4.0

查看:410
本文介绍了创建使用.NET 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();



我如何指定的应用程序池应使用的.NET Framework 4.0?

How do I specify that the app pool should use .NET Framework 4.0?

推荐答案

我从你正在使用IIS7的代码中看到的。除非你绝对要,不要使用IIS6兼容性组件。您首选的方法应该是使用 Microsoft.Web.Administration 管理API。

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.

要使用此创建一个应用程序池,并设置.NET Framework版本到4.0,这样做:

To create an application pool using this and set the .NET Framework version to 4.0, do this:

using Microsoft.Web.Administration;
...

using(ServerManager serverManager = new ServerManager())
{
  ApplicationPool newPool = serverManager.ApplicationPools.Add("MyNewPool");
  newPool.ManagedRuntimeVersion = "v4.0";
  serverManager.CommitChanges();
}

您应该添加到 Microsoft.Web的参考。 Administration.dll 这可以发现:

You should add a reference to Microsoft.Web.Administration.dll which can be found in:

%SYSTEMROOT%\System32 \InetSrv

这篇关于创建使用.NET 4.0的应用程序池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆