Error CS0016: Could not write to output file...


You receive this error when compiling or running your application:

Compiler Error Message: CS0016: Could not write to output file 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\doccontrol\07dc6779\aa4d4b41\en-US\App_GlobalResources.jbhajk-v.resources.dll' -- 'Access is denied. '

This error is caused by a lack of write permissions on either the Microsoft .NET Framework’s Temporary folder or the Windows Temp folder.  Even if the message refers to the Microsoft .NET Framework, the problem may still be permissions of the Windows Temp folder.  The Windows Temp folder is specified by the TMP and TEMP environment variables. By default the TMP and TEMP variables point to C:\Windows\Temp.


There are two users that must be given permission to both of these temporary folders.  The first user is the user accessing the web application and the second is the default Application Pool Identity user.  If the virtual directory is set up for anonymous access, the first user is typically IUSR_<MachineName> (Windows XP) or IUSR (Windows Vista).  The IUSR must have full permissions to both the temporary folders.  The Application Pool Identity is typically set up to use the NETWORK SERVICE user account on your local machine.  Give full permissions to the NETWORK SERVICE user to access both the temporary folders.

Grant full permissions (or at least read / write / modify permissions) for the folder:

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files

You may also wish to add:

<identity impersonate="true" userName="devdomain\youruser" password="yourpassword" />

in your application’s Web.config file.  In this case, grant full permissions to devdomain\yourusername.

To use the anonymous sign in rather than impersonation, permissions may need to be set for the Network Service or the ASP.NET account for the same folder.

See Also

Part VII:  Troubleshooting Applications

Application Generation and Compilation Error Messages