IIS 8及更高版本不支持Servermanager

时间:2015-07-31 04:55:37

标签: c# application-pool servermanager

我想检查IIS中是否存在应用程序池。因为我使用servermanager,如下所示 - >

ServerManager mgr = new ServerManager();
  if (mgr.ApplicationPools["myapplicationpoolname"] == null)
{
//My Procedure to create application pool as app pool doesnt exist
}

这可以在IIS 7.5及以下版本上顺利运行。但是在IIS 8及以上版本中,由于内存泄漏问题,servermanager无法以上述方式使用。我甚至在MSDN上尝试了建议的解决方法,如下所示 - >

 var mgr = ServerManager.OpenRemote("localhost");

仍然没有运气。我被困了,因为我无法在IIS 8及以上版本中使用servermanager :(任何帮助将不胜感激:)

1 个答案:

答案 0 :(得分:0)

ServerManager应该在Windows 8或更高版本中正常工作,请确保您引用位于Windows \ system32 \ inetsrv中的正确版本。还要确保您不是“复制DLL的一个版本”,应始终从GAC加载此DLL并从inetsrv目录中引用,否则您可能会遇到版本问题。