我遇到一个奇怪的问题,IISExpress的Microsoft.Web.Adminstration 7.9.0.0需要在Server 2012上以pipe理员身份运行。
我想要做的是使用PowerShell将网站添加到自定义ApplicationHost.config文件。
我已经在Windows 10和Windows 8.1上testing了我的powershell脚本,并且都使用了admin,但是我被Server 2012卡住了。
我认为这可能是DLL版本IE 7.0.0.0和7.9.0.0之间的冲突。
我在文件旁边添加了DLL,但Add-Type一直从GAC加载它。 很烦人。
我现在唯一能想到的是 有一些GAC许可问题。 这是没有道理的。
# Copied the DLL from C:\Windows\assembly\GAC_MSIL\Microsoft.Web.Administration\7.9.0.0__31bf3856ad364e35\Microsoft.Web.Administration.dll $assemblyPath = "{Path to dll}\Microsoft.Web.Administration.dll" Add-Type -LiteralPath $assemblyPath # This shows Microsoft.Web.Administration loading from the GAC. [appdomain]::currentdomain.getassemblies() $iisApplicationConfig = $(Resolve-Path "{Path to applicationhost.config}\applicationhost.config") $serverManager = New-Object -TypeName Microsoft.Web.Administration.ServerManager -ArgumentList @($iisApplicationConfig) $site = $serverManager.Sites[$BuildDefaultProjectName]
我可以告诉你什么是强迫它使用7.9.0.0
看看这里:C:\ Program Files文件(x86)\ IIS Express \ config \模板\ PersonalWebServer \ aspnet.config
有一个redirect。
<dependentAssembly> <assemblyIdentity name="Microsoft.Web.Administration" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="7.0.0.0" newVersion="7.9.0.0" /> <codeBase version="7.9.0.0" href="FILE://%FalconBin%/Microsoft.Web.Administration.dll" /> </dependentAssembly>
你可以直接尝试完整的IISpipe理软件包https://www.nuget.org/packages/Microsoft.Web.Administration