Monday, 12 March 2007

Mutex could not be created

Working with ASP.Net, have you ever got a:

Server Error in '/xxx' Application. -------------------------------------------------------------------------------- Mutex could not be created.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. bla bla bla ..

I have solved it in various way, but so far the best workaround I have got (thanks mostly to a post of a chap called Joao Morais) is the following:
  • - If you have visual studio 2005 is open, close it
  • - Go to the ASP.NET temporary folder for v2.0 of the framework
  • \Microsoft.Net\Framework\v2.0\Temporary ASP.NET pages
  • - Remove the folder for your application (or all of them)
  • - Reset IIS (on a command line window, >iisreset) [not always needed, but I had to use it sometimes]
  • - First Browse your page from IE (http://localhost/your app)
  • - Then reopen Visual studio
I can only add that a aspnet_regiis -ga \ before resetting IIS, is usually helping, as in 64 bit environments to try to enable/disable the Enable32bitAppOnWin64 IIS Metabase properties.

cscript %SystemDrive%\inetpub\AdminScripts\adsutil.vbs set w3svc/AppPools/Enable32bitAppOnWin64 0
%SYSTEMROOT%\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis.exe -i

cscript %SystemDrive%\inetpub\AdminScripts\adsutil.vbs set w3svc/AppPools/Enable32bitAppOnWin64 1
%SYSTEMROOT%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i

Warning: this is a brute force approach, a bit like formatting an hard disk because the operating system got some cold, use with discrection!

No comments: