Microsoft.Web.Administration.ServerManager 正在连接到 IIS Express 而不是完整的 IIS

2024-01-05

我用它来创建一个实例ServerManager:

[Void][Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration")
$serverManager = New-Object Microsoft.Web.Administration.ServerManager

跑步时$serverManager.ApplicationPools | Select -Property Name I get:

Name
----
Clr4IntegratedAppPool
Clr4ClassicAppPool
Clr2IntegratedAppPool
Clr2ClassicAppPool
UnmanagedClassicAppPool

跑步时$serverManager.Sites | Select -Property Bindings I get:

Bindings
--------
{[http] :8080:localhost}
{[http] *:23700:localhost}
{[http] *:58996:localhost}
{[http] *:62159:localhost}
{[http] *:51643:localhost}
{[http] *:64256:localhost}
{[http] *:50934:localhost}
{[http] *:53107:localhost}
{[http] *:49414:localhost}
{[http] *:59074:localhost}
{[http] *:61886:localhost}
{[http] *:57546:localhost}
{[http] *:63087:localhost}
{[http] *:63838:localhost}
{[http] *:63727:localhost}
{[http] *:60172:localhost}

所以它似乎连接到 IIS Express 而不是我的完整 IIS。我怎样才能让它连接到完整的 IIS?这文档 http://msdn.microsoft.com/en-us/library/microsoft.web.administration.servermanager.aspx没有列出任何接受参数的重载,至少没有列出供公共使用的重载。


该 DLL 有两个版本。 7.0.0.0 包含在完整的 IIS 中,7.9.0.0 包含在 IIS Express 中。这两个版本也在 GAC 中。

指定版本 7.0.0.0 允许访问完整的 IIS:

[Void][Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL")

同时我还发现LoadWithPartialName已弃用,这是当前的方法:

Add-Type -AssemblyName "Microsoft.Web.Administration, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Microsoft.Web.Administration.ServerManager 正在连接到 IIS Express 而不是完整的 IIS 的相关文章

随机推荐