title: CompliationLock throws HttpException when registering areas for ASP.NET MVC unit tests
body: <p>The moment I added a unit test to my ASP.NET MVC application to test some of the area routing, I got an <code>HttpException</code> coming out of the <code>System.Web.Complication.CompilationLock</code> type initializer with the following stack trace.</p>
  
  <pre><code>System.Web.HttpException : The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.
    ----&gt; System.TypeInitializationException : The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.
    ----&gt; System.NullReferenceException : Object reference not set to an instance of an object.
  at System.Web.Compilation.BuildManager.ReportTopLevelCompilationException()
  at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
  at System.Web.Compilation.BuildManager.GetReferencedAssemblies()
  at System.Web.Mvc.BuildManagerWrapper.System.Web.Mvc.IBuildManager.GetReferencedAssemblies()
  at System.Web.Mvc.TypeCacheUtil.FilterTypesInAssemblies(IBuildManager buildManager, Predicate`1 predicate)
  at System.Web.Mvc.TypeCacheUtil.GetFilteredTypesFromAssemblies(String cacheName, Predicate`1 predicate, IBuildManager buildManager)
  at System.Web.Mvc.AreaRegistration.RegisterAllAreas(RouteCollection routes, IBuildManager buildManager, Object state)
  at System.Web.Mvc.AreaRegistration.RegisterAllAreas(Object state)
  at System.Web.Mvc.AreaRegistration.RegisterAllAreas()
  at StpWeb.MvcApplication.RegisterRoutes(RouteCollection routes) in Global.asax.cs: line 16
  at StpWeb.Tests.RoutesTest.TestFixtureSetUp() in RoutesTest.cs: line 11
  --TypeInitializationException
  at System.Web.Compilation.CompilationLock.GetLock(ref Boolean gotLock)
  at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
  --NullReferenceException
  at System.Web.Compilation.CompilationLock..cctor()
  </code></pre>