"CS0016: Could not write to output file" error when starting an app in IIS 7

On Windows 8/Server 2012 there is no support for aspnet_regiis any more. I tried reinstall using windows features: fail. I tried reinstalling IIS: fail. I tried reinstall through WebPI: fail.

I solved the issue by setting the ACL's on the Windows Temp Directory.

Here is a powershell that does the job:

$dir = "C:\Windows\Temp"
$acl = get-acl -path $dir
$new = "IIS_IUSRS","Modify","ContainerInherit,ObjectInherit","None","Allow"
$accessRule = new-object System.Security.AccessControl.FileSystemAccessRule $new
$acl.SetAccessRule($accessRule)
$acl | Set-Acl $dir

For those looking here as I did, if the accepted answer doesn't resolve the issue you might try following this article: http://lordzoltan.blogspot.com/2011/02/aspnet-2-and-4-default-application-pool.html

In summary, it seems that the same error is sometimes displayed when the app pool user doesn't have access to the %TMP%/%TEMP% folder.

You'll need to grant IIS_IUSRS read and modify access over the temp folder of the user the app pool is running as.

This could either be the temp folder in the app pool user's profile, e.g. c:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp, or the system temp folder at c:\windows\temp.

Setting this up this resolved the issue for me.


Sounds like the account that the WCF service is running under does not have access to write to the "Temporary ASP.NET Files" directory.

You could also try re-running regiis.

%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis -i

ASP.NET IIS Registration Tool (Aspnet_regiis.exe)