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 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 ID: 2276
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE
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)
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:
- There is a known bug in .NET Framework 4.7.x that causes this issue
- Web.config file references an assembly that doesn’t exist in the application folder or GAC
- 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:
- Incorrect version of the assemblies that are being used
- PrecompiledApp.config file exists in the application folder
- It’s a 32-bit application and “Enable 32-bit applications” is set to false
- Temporary ASP.NET files may be causing the issue (C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root)
- There are extra files in the publish location (“Remove additional files at destination” is not selected in the Visual Studio Publish Profile)
- The script used for deployment may not be clearing the destination folder properly or it may not be copying all the files
- There is not enough disk space in IIS
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.