Microsoft.Web.Administration.ServerManager is connecting to the IIS Express instead of full IIS

痞子三分冷 提交于 2020-01-04 04:42:06

问题


I'm using this to create an instance of ServerManager:

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

When running $serverManager.ApplicationPools | Select -Property Name I get:

Name
----
Clr4IntegratedAppPool
Clr4ClassicAppPool
Clr2IntegratedAppPool
Clr2ClassicAppPool
UnmanagedClassicAppPool

When running $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}

So it seems to be connecting to IIS Express instead of my full IIS. How can I make it connect to full IIS instead? The documentation doesn't list any overloads accepting parameters, at least none intended for public use.


回答1:


There are two versions of the DLL. 7.0.0.0 is included with full IIS, 7.9.0.0 is included with IIS Express. Both versions are also in the GAC.

Specifying version 7.0.0.0 allows access to the full IIS:

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

Meanwhile I also found that LoadWithPartialName is deprecated, this is the current way to do it:

Add-Type -AssemblyName "Microsoft.Web.Administration, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"


来源:https://stackoverflow.com/questions/25812169/microsoft-web-administration-servermanager-is-connecting-to-the-iis-express-inst

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!