I'm having a strange issue with Microsoft.Web.Adminstration for IISExpress requiring run as administrator on Server 2012.

What I'm trying to do is add a Website to a custom ApplicationHost.config file using powershell.

I've tested my powershell script on windows 10 and windows 8.1 and both work with out admin, but I'm stuck with Server 2012.

I thought it could be something to do with a conflict between DLL versions IE and

I've added the DLL next to the file, but Add-Type keeps loading it from the GAC. Very annoying.

The only thing I can think of now is; there's some sort of GAC permission issue. Which doesn't make sense.

# Copied the DLL from C:\Windows\assembly\GAC_MSIL\Microsoft.Web.Administration\\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. 

$iisApplicationConfig = $(Resolve-Path "{Path to applicationhost.config}\applicationhost.config")
$serverManager = New-Object -TypeName Microsoft.Web.Administration.ServerManager -ArgumentList @($iisApplicationConfig)
$site = $serverManager.Sites[$BuildDefaultProjectName]

I can tell you what's forcing it to use

look in here: C:\Program Files (x86)\IIS Express\config\templates\PersonalWebServer\aspnet.config

there is a redirect.

<assemblyIdentity name="Microsoft.Web.Administration"
culture="neutral" />
<bindingRedirect oldVersion=""
newVersion="" />
<codeBase version=""
href="FILE://%FalconBin%/Microsoft.Web.Administration.dll" />

you could try the full IIS admin package directly https://www.nuget.org/packages/Microsoft.Web.Administration

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.