CompliationLock throws HttpException when registering areas for ASP.NET MVC unit tests

Posted by patridge on Stack Overflow See other posts from Stack Overflow or by patridge
Published on 2010-05-17T18:05:40Z Indexed on 2010/05/17 18:10 UTC
Read the original article Hit count: 543

The moment I added a unit test to my ASP.NET MVC application to test some of the area routing, I got an HttpException coming out of the System.Web.Complication.CompilationLock type initializer with the following stack trace.

System.Web.HttpException : The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.
  ----> System.TypeInitializationException : The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.
  ----> 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()

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about asp.net-mvc-areas