6 Jun, 2007 in Programming by

ASP.NET 2 Error: "A compilation error has occurred" – Resolved!

;

I was in the middle of deploying a new product to our production server but 2 websites are crashing whenever I attempt to access them. Yet, the same code works fine (of course) on my local development pc and staging server.

Here are the event details:

Event Source: ASP.NET 2.0.50727.0
Event ID: 1310

Description:
Event code: 3007
Event message: A compilation error has occurred.
Event time: 6/5/2007 4:18:33 PM
Event time (UTC): 6/5/2007 8:18:33 PM
Event ID: 8155195f68f9454f97ab73ee83689f86
Event sequence: 8
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/1252183813/Root/admin-1-128255483127749852

Trust level: Full
Application Virtual Path: /admin
Application Path: D:\foo\websites\admin\
Machine name: xxxxxx
Process information:
Process ID: 2376
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE
Exception information:
Exception type: Exception
Exception message: (0): error CS0016: Could not write to output file ‘c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\admin\16994e73\70d74143\App_Web_masterpage.master.cdcab7d2.gl-cyqs4.dll’ — ‘The directory name is invalid.
Request information:
Request URL: http://foo/admin/Default.aspx
Request path: /admin/Default.aspx
User host address: xx.xx.xx.xx
User:
Is authenticated: False
Authentication Type:
Thread account name: NT AUTHORITY\NETWORK SERVICE
Thread information:
Thread ID: 1
Thread account name: NT AUTHORITY\NETWORK SERVICE
Is impersonating: False
Stack trace: at System.Web.UI.TemplateParser.ProcessException(Exception ex)
at System.Web.UI.TemplateParser.ProcessMainDirective(IDictionary mainDirective)
at System.Web.UI.TemplateControlParser.ProcessMainDirective(IDictionary mainDirective)
at System.Web.UI.PageParser.ProcessMainDirective(IDictionary mainDirective)
at System.Web.UI.TemplateParser.ProcessDirective(String directiveName, IDictionary directive)
at System.Web.UI.BaseTemplateParser.ProcessDirective(String directiveName, IDictionary directive)
at System.Web.UI.TemplateControlParser.ProcessDirective(String directiveName, IDictionary directive)
at System.Web.UI.PageParser.ProcessDirective(String directiveName, IDictionary directive)
at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
Custom event details:

The unique aspects of this error are:

Event message: A compilation error has occurred.

Exception message: ‘The directory name is invalid.

Thread account name: NT AUTHORITY\NETWORK SERVICE

and that this is ASP.NET 2.0 on Windows 2003 R2.

This MSKB Article was the closest thing I could find describing the error but it only applies to .NET 1.0 & 1.1. There are also several other forum threads describing similar issues, but the “The directory name is invalid.” part of the error makes this different.

As it turns out, since the Application Pool for these websites are running as the Network Service user, which doesn’t have a HOME directory, there wasn’t a Temporary directory to be found in which to compile these pages at runtime. The default TEMP & TMP values are set to %USERPROFILE%\Local Settings\Temp.

Also, don’t let the Temporary ASP.NET Files path in the error confuse you, that’s not the source directory that it’s complaining about.

So… to fix the problem:

1. Set the TEMP & TMP System Environment Variables to: %windir%\Temp

2. Run: iisreset

3. Now refresh the web site and hopefully everything works since the Network User has a temporary directory to compile the pages then copy to Temporary ASP.NET Files.

Good Luck!

Share on Twitter

3 Responses so far | Have Your Say!

  1. Wavatar

    P A  |  July 7th, 2010 at 10:42 am #

    Hi
    I have the same error!!!
    what happend?
    did you find any solution?

  2. Wavatar

    Roger  |  July 7th, 2010 at 1:55 pm #

    @PA Hello, yes I found a solution and have to use it regularly.

    This is all you need to do:
    1. Set the TEMP & TMP System Environment Variables to: %windir%\Temp
    2. Run: iisreset

  3. Wavatar

    Rene  |  May 19th, 2011 at 2:23 am #

    I did 1. Set the TEMP & TMP System Environment Variables to: %windir%\Temp
    2. Run: iisreset

    But the problem still-..
    What more can I DO??
    thanks..