Tags:Microsoft, ASP.NET, v1.1.4322, running on Windows XP SP2, Compilation Error Message: CS0016: Could not write to output file 'c:\windows\temp\<appname>\xxxxxxxx\xxxxxxxx\xxxxxx.dll' -- 'The directory name is invallid
I'm working with a WIndows XP SP2 image that was provided to me by a customer and I am trying to debug a problem with an asp.net 1.1 application that we are installing on the image. I have been reading a lot of posts related to this subject all over the web, and I have narrowed the problem down to the fact that ASP.NET is trying to use the Administrator's temp directory instead of the %systemroot%\temp directory for the intermediate compilation files before it copies them to its assigned temp directory.
Normally this error message would be caused by an invalid TEMP directory (as specified by the system TEMP variable) or missing permissions on the TEMP folder for ASP.NET or NetworkService. As i understand how ASP.NET compilation is supposed to work it uses the TEMP env var to build the binaries as it compiles and then copies the final file to its configured temp directory to run from. I checked that my system TEMP variable is set to %SYSTEMROOT%\temp and so is TMP. And I checked the permissions on this folder and added full control for NetworkService and ASP.NET, but it had no effect. Changing the Admin's TEMP variable to another value wouldn't stick and kept getting reset on each reboot. That doesn't seem like a valid solution anyway.
I tried changing the ASP.NET temp directory by modifying machine.config to set tempDirectory="c:\windows\temp" on the compilation tag, but that just changes the compilation target from c:\windows\microsoft.net\framework\v1.1.4322\Temporary ASP.NET Files to c:\windows\temp. It still uses another TEMP directory to build the dll before it copies to the tempDirectory it runs it from. Somehow its getting the Administrator's personal TEMP variable instead of the system variable. I am running as Administrator for testing purposes
I found the only way I could make this go away was to add full control permissions for ASP.NET on c:\documents and settings\administrator\Local Settings\Temp. I just don't think this will be an accepted solution for my customer since they are very security-minded and will not want to create privileges in inappropriate places. How can I make ASP.NET use the system temp folder again instead of the user's temp folder?
Hi gadillon just offering ideas only since your question has received no responses at all. I lack experience in this so it is just a gesture of help. I dont know if you can actually move this folder since it is assigned to the administrator by default. and the directory c:\documents and settings\administrator\Local Settings\Temp. Is far safer than C: windows asp.net 1.1 has an updated version too. Sometimes the new versions offer more? http://www.asp.net/downloads/essential/
Thanks Merete. Upgrading to 2.0 or higher isn't an option for this app since its legacy under support contract. I've seen a lot of weirdness in the past with the way Windows handles the environment variables and what environment you end up with when you impersonate or change contexts. I'm afraid I'm stuck with something like that, but no idea how to break it loose.
Dont worry about accepting my comments here gadillon if they doen tassist you. looking in your account you have only asked this in one zone try reposting this to 2 new zones, reduce the points. or delete this and repost to three zones. Cross posting it's called. Often times it's a good idea to post to a zone on topic such as http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/ but may not have a lot of experts there, so you post again to a zone with more experts like this one http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SQL-Server-2005/ So over these zones you have pretty good coverage.
gadillon, I have couple of questions .. Please bear with me while I understand the issue here.. You said "Somehow its getting the Administrator's personal TEMP variable instead of the system variable" What system variable you are talking about?
Isnt Administrator's personal TEMP variable is the environment variable for TEMP, that asp.net uses during compilation? Or Am I missing something here
Also, I am wondering, why would this compilation issues matter to your customer. Arent you only deploying the site after compilation?
I'm talking about the system TEMP variable, which is usually set to %SYSTEMROOT%\temp. Looking at a typical windows XP machine, ASP.NET doesn't normally have any access at all to the Administrator's temp directory, so I dont; see whay I should have to grant access. We have other Windows XP images where this ASP.NET application works fine with no permissions changes for ASP.NET, so I'm trying to understand what makes this system different.
I'm afraid it does matter to the customer, since the application gets compiled when you access the page, so they will get a CS0016 error "Directory invalid" if this isn't setup right. I could just grant the permissions and continue, I've been able to make it work that way, but I think its wrong.
Here is my understanding of how the asp.net 1.1 execution happens on the server. Let me know if I am missing something -------------------------------------------------------------------------------------------------------------------- If you deploy a compiled .net web application, no more compilation on the server happens, only the shadow copying onto the Temporary ASP.NET files. Thats why we do not provide any of the class files to the customer
If you are talking about JIT compilation, that is just to turn IL code into machine code, but it has nothing to do with asp.net, its how the CLR works.
On the other hand, if you are talking about the inline code in your aspx page, it does get compiled the first time it is accessed, but it is only placed under the same shadow copy folder in the Temporary ASP.NET files. ------------------------------------------------------------------------------------------------------------------------- So, I really do not see why these development compilation issues matter to the client still.. The compliation, if at all happens during the execution is different from the compilation we do on VS.NET
And about the System TEMP variable, I am not sure what exactly it is.. I only know about the TEMP Environment variable, which you can find out from SET command
Excuse my ignorance, if I am missing something big here..
yes the system TEMP variable is an environment variable. Its distinct from the Administrator's TEMP variable which supercedes the system TEMP variable when you are running as Administrator.
If there is no compilation required then why do I get a compilation error CS0016? I must have made a mistake in setting up this question, because the error message is actually listed in the Tags. This error only happens on a deployed system, not on the developer's system. VS.NET is not even installed.
Let me restate the error message: Compilation Error Message: CS0016: Could not write to output file 'c:\Windows\Microsoft.NET\Framework\Temporary ASP.NET Files\<appname>\xxxxxxxx\xxxxxxxx\xxxxxx.dll' -- 'The directory name is invallid'