Jerry Orman

Adventures in SharePoint

System.InvalidOperationException: Mutex could not be created.

System.InvalidOperationException: Mutex could not be created.

Rate This
  • Comments 10

We've seen a few of these issues come through lately andwanted to get something posted so people can find it.

If you created a custom account to run the process that ASP.NET is running in, you may encounter the following exception:

System.InvalidOperationException: Mutex could not be created.

Stack Trace: 
[InvalidOperationException: Mutex could not be created.]
   System.Web.Compilation.CompilationMutex..ctor(String name, String comment) +3464689
   System.Web.Compilation.CompilationLock..cctor() +158

[TypeInitializationException: The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.]
   System.Web.Compilation.CompilationLock.GetLock(Boolean& gotLock) +32
   System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +114

[HttpException (0x80004005): The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +3426871
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +88
   System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +149
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

Note:  The error will appear to be random, but once it appears, will remain until a reboot or until the handles to the mutex are closed.

Cause:
======
This occurs because the permissions on the following registry key no longer have your custom account:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\2.0.50727.0\CompilationMutexName

The compilation mutex gets it's permissions from this registry key and with your custom account missing, the process running ASP.NET cannot get a handle to the mutex and fails during compilation.

Resolution:
=========

  1. Run the following to add your custom account to the registry key permissions:
             ASPNET_regiis -ga domain\account.
  2. Either restart the server or close the handles to the mutex (see below)

To close the handles to the Mutex:

  1. Download and launch Process Explorer from www.sysinternals.com
  2. From the Find menu, select Find Handle or DLL
  3. In the Handle or DLL substring box, type “mutant” (without quotes) and click Search
  4. Click the Handle or DLL column heading to sort the items and find a mutex that starts with CL.  The handle will typically be devenv.exe (the IDE for Visual Studio) and aspnet_wp.exe or w3wp.exe.  The handle will look similar to:
  5. \BaseNameObjects\CLbdd6aa8f
  6. Select the handle in the search box and Process Explorer locates the Process and the handle in the main window
  7. Right-click the handle in the main window and select Close Handle

Additional Info:
============
The error may occur anytime you run ASP.NET as a custom account and the above mentioned registry key does not have the account listed in the permissions.

If you receive the error and you are running with a custom account on IIS 6 in worker process mode (code running in w3wp.exe), you can add your custom account to the IIS_WPG group on the server.  The IIS_WPG group is granted access to the registry key by default.

  • Way behind on posting and cleaning out the inbox, but wanted to capture this information.  Just got a new laptop at work (which is part of the reason I'm so far behind) and as is the norm you end up...
  • Today I was stuck for the first time with this: System.InvalidOperationException: Mutex could not be

  • Mutex could not be created 的异常错误解决办法

  • Hi Jerry

    it work works great for me.. although when i restart my workstation the saaaame problem hapnd, i fixed it doing the same steps you published

    my question is... is this going to hapn everytime i reset my pc? isnt there a way to keep it permanent or is there something im just doing wrong or something to check maybe??

    many thanks in advanced bro

  • Hi Jerry,

    I receive the same exception using .NET 1.1

    Is the the resolving solution be the same as for .NET 2.0?

  • 1、 当前标识(NT AUTHORITY\NETWORK SERVICE)没有对“C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary

  • 正解: http://blogs.msdn.com/jorman/archive/2006/07/24/system-invalidoperationexception-mutex-could-not-be-created.aspx 1) C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ASPNET_regiis -ga yourdomain\youraccount 2) iisreset

  • On the recommendation of a trusted co-worker who shall remain unnamed, I had installed the March CTP

  • To clean up an old farm from some setup errors, I recently rebuilt the farm from bare metal, re-attaching

  • To clean up an old farm from some setup errors, I recently rebuilt the farm from bare metal, re-attaching

Page 1 of 1 (10 items)
Leave a Comment
  • Please add 6 and 3 and type the answer here:
  • Post