Asp.Net Runtime Error: The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.

Last post 03-04-2009 5:52 PM by aneesh.aravind. 12 replies.

Sort Posts:

  • Asp.Net Runtime Error: The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.

    04-05-2006, 7:04 AM
    • Member
      10 point Member
    • bala_excel
    • Member since 04-05-2006, 10:16 AM
    • Posts 2

    HI all,

    I migrated my webapplication from VS 2003 to  VS 2005. and i am running on win xp Professional sp2. After migrating. i am getting the following error . 

    "The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception." the error is shown in the following line

    "<%

    @ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %>"

    i looked into the net but couldnt fix this.

    any help would be highly appreciated

    Thanks in advance,

    Bala

  • Re: Asp.Net Runtime Error: The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.

    04-06-2006, 2:25 PM
    • Contributor
      5,787 point Contributor
    • davidebb
    • Member since 06-11-2002, 12:31 PM
    • Redmond, WA
    • Posts 1,159
    • AspNetTeam

    Hi Bala,

    Some questions:

    • Are you seeing under IIS, or the VS test web server?
    • Does restarting VS and the Web Server solve it?
    • Do you also this this for other 2.0 apps, or just for this one?
    • Are you running as admin on your machine, or as a regular user?

    thanks,
    David

  • Re: Asp.Net Runtime Error: The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.

    04-07-2006, 1:04 AM
    • Member
      10 point Member
    • bala_excel
    • Member since 04-05-2006, 10:16 AM
    • Posts 2

    Hi David,

    Thanks for your reply,

    I have restarted both my VS and IIS but it didnt turn fruitful. and the application is running under IIS.

    I am getting this error while building the application.

    I have admin rights.

    I am not getting any build error when I create a new website in VS 2005

    kindly let me know what I am doing wrong !

    Thanks in advance

    Bala

  • Re: Asp.Net Runtime Error: The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.

    04-10-2006, 3:17 PM
    • Contributor
      5,787 point Contributor
    • davidebb
    • Member since 06-11-2002, 12:31 PM
    • Redmond, WA
    • Posts 1,159
    • AspNetTeam

    To be sure, is this an error that you see in the error list in VisualStudio, or at runtime in the browser?

    This error could happen if a process is already holding on to the Mutex object that ASP.NET tries to use for this application (it's used to protect compilations).  But I really can't explain how restarting all processes doesn't fix it.  Even rebooting doesn't help?

    I would use procexp to investigate this, but this is a little adanced.  Look for a Mutex (aka Mutant) with a name that starts with "CL", and check what process might be holding on to it.

  • Re: Asp.Net Runtime Error: The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.

    04-24-2006, 8:57 AM
    • Member
      29 point Member
    • gleizerowicz
    • Member since 06-28-2002, 7:41 AM
    • Moorestown, NJ, USA
    • Posts 5
    Thanks for the procexp tip - I deleted a Mutant (just picked one of two that started with CL) and I could build again.  It was being held by aspnet_wp.exe.  I have my processModel running as a domain account and my IIS 5.1 on XPSP2 application running in Low Isolation mode.  I had to set it up this way to use integrated security to connect to my SQL Server database.  Could this configuration cause any problems?
  • Re: Asp.Net Runtime Error: The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.

    04-24-2006, 1:45 PM
    • Contributor
      5,787 point Contributor
    • davidebb
    • Member since 06-11-2002, 12:31 PM
    • Redmond, WA
    • Posts 1,159
    • AspNetTeam
    I would think this should be ok, but I can't explain why you were getting this.  It'll be interesting to see whether it keeps working now, or whether some sequence of action will cause it to get back into that bad state.
  • Re: Asp.Net Runtime Error: The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.

    04-24-2006, 2:29 PM
    • Member
      29 point Member
    • gleizerowicz
    • Member since 06-28-2002, 7:41 AM
    • Moorestown, NJ, USA
    • Posts 5

    I can reproduce it easily:

    1. Open VS

    2. Build one of my two websites in this solution

    3. Browse to the application in IE, get runtime compilation lock error

    Then, after closing the mutex handle held by devenv.exe:

    1. Refresh browser, use app

    2. Build website in VS, get mutex or compilation lock error

    From here I close the mutex handle held by aspnet_wp.exe

    This behavior is consistent.  Would you like to see my solution file offline?  I'd be happy to give you whatever info would be helpful.

  • Re: Asp.Net Runtime Error: The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.

    04-24-2006, 2:43 PM
    • Contributor
      5,787 point Contributor
    • davidebb
    • Member since 06-11-2002, 12:31 PM
    • Redmond, WA
    • Posts 1,159
    • AspNetTeam

    Yes, please send me email offline and I will include a few people who will help out with the investigation.

    thanks,
    David

  • Re: Asp.Net Runtime Error: The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.

    07-15-2006, 10:35 AM
    • Member
      390 point Member
    • dstgroup
    • Member since 12-29-2004, 3:41 PM
    • Thunder Bay, Ontario
    • Posts 78
    Any resolution on this yet? I have been stuggleing with this issue for a few hours and can't seem to resolve it. I too am using a domian account and IIS and VS are fighting each other during compliation. The worked fine for weeks until today. After a reboot this morning it started happening.
    Geoff Van Brunt
    DST Consulting Engineers
  • Re: Asp.Net Runtime Error: The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.

    07-17-2006, 8:28 AM
    • Member
      29 point Member
    • gleizerowicz
    • Member since 06-28-2002, 7:41 AM
    • Moorestown, NJ, USA
    • Posts 5

    Sorry Geoff - no resolution yet.  My workaround was to remove the web project from my solution, then recreate it as a file system web project instead of a local IIS project.  To debug, I browse to my local site and attach to the process.

    I have some steps that MS Developer Support suggested; they didn't work for me, but if you contact me offline I'll be happy to send them to you and you can try them yourself.

    Greg

  • Re: Asp.Net Runtime Error: The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.

    07-17-2006, 4:46 PM
    • Member
      5 point Member
    • ChadLindstrom
    • Member since 07-14-2006, 8:28 PM
    • Posts 1
    This happened to us the same morning on reboot.  It seemed to coincide with a windows update.

    Not impressed.
  • Re: Asp.Net Runtime Error: The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.

    02-08-2009, 2:41 AM
    • Contributor
      4,209 point Contributor
    • SyntaxC4
    • Member since 07-13-2007, 2:25 PM
    • Guelph, Ontario
    • Posts 690

    Hi all,

    Take a look at this forum: http://forums.aspfree.com/net-development-11/asp-net-debugging-trouble-22489.html

    Seems he found an issue with his web.config file after the file conversion.

    Hope this helps.

    *** REMINDER ***
    If you find this post useful, Please click the 'Mark as Answer' Button.

    *** DISCLAIMER ***
    All Code is provided AS IS.
  • Re: Asp.Net Runtime Error: The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.

    03-04-2009, 5:52 PM

    I had the same error message and here's what I found out. If I have a project open in VS 2005, and am debugging, my ASP.NET Development Server (the little icon in the tray on the RHS) latches on to the files and creates a lock on the files.

    Here's how to reproduce the scenario:

    • Open a web project in VS2K5.
    • Debug the web application (F5) so that the ASP.NET Development Server gets instantiated.
    • Stop debugging the web app
    • Close the project in VS do not exit VS
    • Open a new instance of VS2K5 under a different user's credentials (Run As)
    • Open the same project in the new instance of VS2K5
    • Try to build the Project. You should get the error.

    To get around this error, look in your icon tray at the bottom right hand corner and find the icon for ASP.NET Developement Server and stop it. You should be able to compile the Project now without any error.

    HTH.

Page 1 of 1 (13 items)