Microsoft.Web.Administration.dll是可再发行的吗?

时间:2012-04-20 14:41:11

标签: c# iis-7

我们使用客户机中IIS的ServerManager类访问默认端口号。但是控制台没有运行某些机器并显示需要Microsoft.Web.Administration.dll。这个程序集是Redistributable吗?或者有没有其他方法来获取默认端口号? 我使用下面的代码来获取端口号。

using (ServerManager serverManager = new ServerManager())
        {
            SiteCollection allsites = serverManager.Sites;
            foreach (Site site in allsites)
            {
                if (site.Name == "Default Web Site")
                {
                    BindingCollection allBindings = site.Bindings;
                    foreach (Binding bind in allBindings)
                    {
                        if (bind.Protocol == "http")
                        {
                            PortNo = bind.BindingInformation.ToString();
                            int portNoLenth = PortNo.Length; PortNo = PortNo.Substring(2, portNoLenth - 3); break;
                        }
                    }
                }
            }
        }

请帮我解决这个问题。

2 个答案:

答案 0 :(得分:3)

不,它不可重新启动,它应该安装在带有IIS的计算机上。即使你这样做,也可能无法工作,因为它依赖于需要存在和注册的其他库(本机代码DLL)。

答案 1 :(得分:0)

我知道这是一篇较旧的文章,但是我相信它现在可以重新分发,因为如果您尝试添加对它的引用,它会作为扩展名下的程序集出现。

Microsoft.Web.Administration reference