views:

172

answers:

3

I've been battling for two days tracking down a mysterious error when compiling an ASP.NET website. The error is the (quite famous) CS0016: "Unable to write to output file [filename] - directory is invalid".

I have discovered after two days of debugging that the cause of my problem is that the NetworkService somehow does not have the necessary rights to C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files. I have added "Everyone" with full rights to the folder - but I am still unable to access http://localhost and I can see using Process Monitor from SysInternals that the NetworkService account gets a "NAME NOT FOUND" when trying to create a DLL-file in that directory. My interpretation is that it does not have sufficient rights to the folder somehow.

However - when I fire up Visual Studio and attach a debugger the files are compiled using my domain user (JohnDoe for reference) and for some reason that works out fine - as if the domain user account contains further rights than I am unable to give the local users on my machine - which puzzles me a lot.

My two question to you guys are: Why is it that when I add "Everyone" with full rights to a folder the NetworkService still does not have the rights neccessary to create the temporary files needed? And which rights does my JohnDoe domain user have which I am unable to grant my local users on my machine?

+2  A: 

You need to grant the NetworkService right permission to your system temp directory (the directory in the Temp variable). This is because the temporary asp.net files gets written to this temporary folder first before being moved to the ASP.NET Temporary Internet Files directory.

Galilyou
It already has full rights
Well, actually I'm not sure, maybe you should try here "http://support.microsoft.com/kb/825791/en-us"
Galilyou
+1  A: 

It turned out that I had a TEMP environment variable pointing to a RAM-drive which didn't exist anymore... It had nothing at all to do with the user issues mentioned. Lesson learned: There are both TEMP variables for the user AND FOR THE SYSTEM!!! THERE ARE TWO!!! I had already thought of that scenario and changed the variable for the user - but I missed the one regarding the system. Somehow it is kinda difficult for a computer to write temporary files to a folder on a drive it cannot access....

Ø"#¤/(%"/#¤%"(/=("(!§##§¤%"!#!"!!

Case closed.

Shouldn't my answer be accepted? as I mentioned this case and provided a url in a comment!??
Galilyou
My fault - I'm a little inexperienced in StackOverflow usage :o)
A: 

I had this issue for the few days at a new client. I was using a VMWare image, pointing to source code on a share. I gave the user "everyone" full access, but was still gettign issue.

Since I copied the share to the VM disk, haven't had the problem yet (just tried a few times so far, but saw consistent success vs the consistent failure I was having before). Was happening with both VS2005 and VS2008.

NealWalters