Over the last year we've found and fixed a few ASP.NET 2.0 compilation bugs that people have reported running into.
The cause of these bugs is varied - but the root cause usually is related to having projects structured with particular cross page circular dependencies, and they are often triggered when massive file-changes occurs on the system (for example: an anti-virus program updates all of the timestamps on files at once).
Example Error Messages:
The below error messages are examples of the types of runtime exceptions you might see if you run into one of these compilation issues:
Unable to cast object of type 'ASP.masterpage_master' to type 'ASP.masterpage_master'.
Could not load file or assembly 'App_Web_e9dbmaj, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. Or:
Compiler Error Message: CS0006: Metadata file 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\cms.web\44e73607\b028acb3\App_global.asax.fakktchx.dll' could not be found Or:
System.InvalidOperationException: The resource class for this page was not found. Please check if the resource file exists and try again
Workaround for these issues:
If you have an application that starts throwing one of these errors, you can usually apply an immediate workaround that fixes it by opening your application's web.config file and setting the batch="false" attribute on the <compilation> section:
<compilation debug="false" batch="false"></compilation>
This tells ASP.NET to dynamically compile individual .aspx/.ascx files into separate assemblies. This avoids the circular reference issue that triggers the exception.
You can also temporarily fix it by deleting the files within the "Temporary ASP.NET Files" Cache using the below steps:
- Click the Windows Start button, click Run, type iisreset /stop, and then click OK.
- Open the DriveLetter: WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files directory.
- Delete all files and all folders in the directory that you located in step 2.
- Click Start, click Run, type iisreset /start, and then click OK.
More details on these workarounds can be found in Microsoft KB #934839.
QFE HotFix Patch for these issues now available for download:
As an alternative to applying the above configuration workaround, you can also now download and apply a Microsoft QFE HotFix patch that fixes the reported compilation issues we've seen.
The direct download link to this compilation QFE HotFix patch is here. You can find other commonly requested Visual Studio and .NET Framework QFE HotFixes on this page here.
Important: People sometimes ask me whether they should install QFE HotFixes proactively (before they ever seen an issue). I always recommend against doing this - since QFE hotfixes go through targeted testing (to verify a specific issue is fixed), and don't go through a complete product end to end sign-off. As such, I'd recommend only applying one of if you are running into the specific issue it targets above.
Contacting Microsoft Product Support:
If you have any problems installing the patch or find that you still see compilation issues after you install it, you'll want to contact Microsoft product support for assistance and they'll help debug it further. Calls to Microsoft Product Support are free if they are related to a product bug (either a QFE HotFix request or a product bug you are running into). You can find details on how to contact Microsoft product support on this page (it allows you to lookup the local phone number to use by country).
Most versions of Visual Studio also come with free product support tickets (for example: VS Pro with MSDN Premium comes with 4 support tickets per subscription). You can use these support tickets for getting help using .NET or Visual Studio (for example: to get help chasing down a bug or performance problem in your own code, or to learn how to use a particular feature in the framework or IDE).
There are some really, really phenomenal engineers in Microsoft product support who are great to work with if you have problems. Here are some fantastic blogs that I highly recommend subscribing to from a few of them in the .NET Framework / Visual Studio space:
If you ever run into a problem you can't figure out, or have an issue with a production application that you want immediate help on, give Microsoft product support a call and you'll have someone like the folks above attach a debugger and help you figure out what is going on.