The file has not been pre-compiled error and solution

This post has been republished via RSS; it originally appeared at: IIS Support Blog articles.

This intermittent error may show up in Event Viewer when your application fails to load: “The file has not been pre-compiled, and cannot be requested”. The intermittent nature of the issue makes it difficult to troubleshoot it but there are a couple of possible root causes and solutions.

The error message

Here is the full error message from Event Viewer (Event ID is 1309):

 

Event code: 3005
Event message: An unhandled exception has occurred.

Application information:
Application domain: /LM/W3SVC/1/ROOT/ApplicationX-1-132102041647233704
Trust level: Full
Application Virtual Path: /ApplicationX
Application Path: E:\inetpub\wwwroot\ApplicationX\
Machine name: ServerX

Process information:
Process ID: 2276
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE

Exception information:
Exception type: HttpException
Exception message: The file ‘/ApplicationX/Login.aspx’ has not been pre-compiled, and cannot be requested.
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)

 

clipboard_image_0.jpeg

 

Solution

In most cases, the root cause of the issue is that the application is not able to load one or more libraries. An assembly that web.config references is probably not available in the application directory or GAC.

The most common causes of this error:

  1. There is a known bug in .NET Framework 4.7.x that causes this issue
  2. Web.config file references an assembly that doesn’t exist in the application folder or GAC
  3. An assembly file that exists in the application folder is not referenced by the web.config file

 

For the 2nd and 3rd causes, Turning on Assembly Binding Logging helps finding which assembly is causing this issue.

 

Other possible causes:

  1. Incorrect version of the assemblies that are being used
  2. PrecompiledApp.config file exists in the application folder
  3. It’s a 32-bit application and “Enable 32-bit applications” is set to false
  4. Temporary ASP.NET files may be causing the issue (C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root)
  5. There are extra files in the publish location (“Remove additional files at destination” is not selected in the Visual Studio Publish Profile)
  6. The script used for deployment may not be clearing the destination folder properly or it may not be copying all the files
  7. There is not enough disk space in IIS

 

clipboard_image_1.png

Publish options in Visual Studio

 

I won’t be able to provide solution for each of these causes but I am hoping that knowing these possible causes will help narrowing the issue down.

 

Here are a helpful ASP.NET forum topic and a MSDN blog post about this issue.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

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