SharePoint ASP.NET Compilation Errors (CS0016)

I encountered a rather frustrating issue with SharePoint 2013. Like most farms, this farm has a specific Domain User running the IIS Application Pool handling Web Applications. These users had a Windows Profile created (this is done by elevating the user temporarily to Administrator, then running an application such as cmd.exe or notepad.exe as that user). “Out of the blue”, when users would navigate to certain built-in pages (e.g. List Settings, or Version Settings underneath List Settings)  they would generate errors similar to the below in the Application Event Log.

In addition, when attempting to publish SharePoint Designer Workflows in SharePoint 2010 mode, SharePoint Designer would present the message:


Another form of error the end user received was:


As other suggestions on the Internet indicated, rebooting the server did work, for a little while. But eventually the errors would return (don’t ask me why they wouldn’t present themselves immediately, I don’t know!). Eventually, ProcessMonitor showed that files could not be created in the user’s Temp directory running the IIS Application Pool! Lo and behold, when navigating to C:\Users\serviceaccount\AppData\Local\, the Temp directory was missing!

Simply creating the Temp directory, so C:\Users\serviceaccount\AppData\Local\Temp resolved the issue immediately, no iisreset or restart required. The key here is that the user performing the compilation of ASP.NET pages needs to have a valid %Temp% path, where ever that location may be — specifically, the error message “The directory name is invalid” refers to this %Temp% location.


  1. We normally create local profiles for all the service accounts to avoid these types of issues. I adapted the method used from AutoSPInstaller to semi-automate this:

    Of course, you could also just log onto each box as each user but that’d be icky. :)

    • This user actually has a local profile, as noted in the post (the farm has been online for a couple of months at this point). The user’s Temp folder was deleted by an unknown process.

  2. Thank you for this Trevor, good stuff man!

  3. You are simply awesome.. Amazing article. I had the similar issue in one of SP2013 environment where the site was working on one WFE and giving the error on the other WFE, following your post found the temp folder was missing on the problematic server for the app pool account. Created the temp folder as you mentioned and site came up without any iisreset or reboot.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.