Home » Development » The file has not been pre-compiled, and cannot be requested (Solved)

The file has not been pre-compiled, and cannot be requested (Solved)

You may run into “The file has not been pre-compiled, and cannot be requested” error intermittently while accessing your ASP.NET application. The intermittent nature of the issue makes it hard to troubleshoot but there are a couple of common causes of this issue. Let’s have a look a them and the possible 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.
Event time: 8/13/2019 5:30:37 PM
Event time (UTC): 8/13/2019 9:30:37 PM
Event ID: fb6cbd06310e4e1691aea324e43874ae
Event sequence: 5
Event occurrence: 3
Event detail code: 0

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)

The file has not been pre-compiled, and cannot be requested

Root cause and solution for “The file has not been pre-compiled, and cannot be requested” error

This issue occurs because the application is not able to load one or more libraries it needs. Most of the time, an assembly that web.config references is not available in the application directory or GAC.

Here are the most common causes of the issue:

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

For the 2nd and 3rd causes, I would recommend turning on Assembly Binding Logging to see which assembly is causing this issue: How to enable Assembly Binding Logging (Fusion Log Viewer – fuslogvw.exe)?

Other causes:

  1. Incorrect version of the assemblies are being used
  2. PrecompiledApp.config file exists
  3. It’s a 32-bit application and “Enable 32-bit applications” is set to false
  4. Temporary ASP.NET files are 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. If there is a script used for deployment, it may not be clearing the target folder properly or it may not be copying all the files from the source
  7. There is not enough disk space in IIS
File publish options for solving "The file has not been pre-compiled, and cannot be requested" error
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 StackOverflow post, an ASP.NET forum topic, and a MSDN blog post about this issue.

If you find yourself troubleshooting an assembly related issue, this post may help: How to find out the Public Key Token for an assembly (DLL) file?

Ned Sahin

Blogger for 20 years. Former Microsoft Engineer. Author of six books. I love creating helpful content and sharing with the world. Reach me out for any questions or feedback.

1 thought on “The file has not been pre-compiled, and cannot be requested (Solved)”

  1. I disagree with Step 4 in this article…

    For us, just removing the files under “C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root” did NOT work.

    Instead, we had to delete ALL of the files and folders under:

    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files

    Only then did the error go away.

    Reply

Leave a Comment