<Update Sept 18, 2013>

The hotfix which resolves this issue has been released - http://support.microsoft.com/kb/2888303.  See solution #2 below.

</Update>

<Update Sept 17, 2013>

A hotfix has been built and a link to the KB article will be available shortly.

Updated the hotfix to http://support.microsoft.com/kb/2836939/en-us, and corrected information about OS Family 3 (Windows Server 2012).

</Update>

Symptom

Your ASP.NET application which uses the System.Runtime.Caching.MemoryCache class and is hosted in a Windows Azure WebRole begins throwing the following exception some time after August 31, 2013:

System.Exception: Type 'System.Threading.ExecutionContext' does not have a public property named 'PreAllocatedDefault'

The callstack may look something like:

System.Web.Util.ExecutionContextUtil.GetDummyDefaultEC()
System.Web.Util.ExecutionContextUtil..cctor()
System.Web.Util.ExecutionContextUtil.RunInNullExecutionContext(System.Action)
System.Web.Hosting.ObjectCacheHost.System.Runtime.Caching.Hosting.IMemoryCacheManager.UpdateCacheSize(Int64, System.Runtime.Caching.MemoryCache)
System.Runtime.Caching.CacheMemoryMonitor.GetCurrentPressure()
System.Runtime.Caching.MemoryMonitor.Update()
System.Runtime.Caching.MemoryCacheStatistics.CacheManagerThread(Int32)
System.Threading.ExecutionContext.runTryCode(System.Object)

 

Root Cause

The August 2013 Windows Azure Guest OS Release began deployment into the production environment on August 31, 2013, with most hosted services which use automatic guest OS updates being upgraded starting around September 7.  This OS release contains the standard security patches, including the fix in http://support.microsoft.com/kb/2836939/en-us which is an ASP.NET hotfix for .NET Framework 4.  This ASP.NET patch introduced a regression which causes the above exception when using System.Runtime.Caching.MemoryCache in an ASP.NET application.

Note that this issue does not impact OS Family 3 (Windows Server 2012) since this OS comes with .NET 4.5 which is not impacted by the ASP.NET hotfix.

 

Solution

The following are the possible solutions, roughly ordered by ease of implementation:

  1. The easiest fix is to roll back to the previous Windows Azure Guest OS Release.  This can be done via the management portal and changing Operating System Version to 1.25, 2.17, or by updating the .cscfg file and change osVersion=* to:
  2. A hotfix which resolves this problem is available via http://support.microsoft.com/kb/2888303.  If solution #1 is not viable for you then you can include this hotfix in your package and install it via a startup script.  Once the next Azure Guest OS release is released you can then remove this hotfix from your package.
  3. Upgrade to OS Family 3 which uses Windows Sever 2012.
  4. Remove the use of System.Runtime.Caching.MemoryCache from the ASP.NET application
    

 

The next Windows Azure Guest OS Release will include the ASP.NET hotfix to resolve this issue and should begin rolling out to Azure by early October.  If you have chosen solution #1 (roll back to the previous Guest OS), once this new Guest OS is released you will be able to upgrade to this release or set your OS configuration back to Automatic updates.  To be notified when the next Guest OS begins deployment to production sign up for the RSS feed at http://sxp.microsoft.com/feeds/3.0/msdntn/WindowsAzureOSUpdates.