I’ve recently solved this issue on my machine and thought I would share this with everyone.
Visual Studio 2012 is configured to use IIS Express by default and on my laptop I noticed that I started to see this error.
So I looked at how best to resolve this issue.
Sites from Web Matrix worked fine in IIS Express and IIS Express would launch from the command line.
I started by using Process Monitor to troubleshoot this issue.
I started Process Monitor and set up a filter like this.
I started by looking at the Process Start event.
I looked at the Properties of this event and noted that the Process was starting like this.
"C:\Program Files (x86)\IIS Express\iisexpress.exe" /config:"C:\Users\MyUserName\Documents\WebMatrix\config\config\applicationhost.config" /site:"WebApplication2(1)" /apppool:"Clr4IntegratedAppPool"
Then I tried running this from a command prompt and see this underlying error.
”The following site was not found in the configuration file: ‘WebApplication2(1)’”
So now I know that
a) My IIS Express install is using the Web Matrix Config file.
b) It can’t find the site from my Visual Studio 2012 solution.
When Visual Studio 2012 is creating the site in IIS Express it is updating the config file at C:\Users\MyUsername\Documents\IISExpress\config\ and not the Web Matrix one.
I then remembered than when I installed Web Matrix it told me it could not access the IIS Express config file and if I would like to create a new config file.
It turns out that this adds a new REG_SZ value called CustomUserHome at HKEY_CURRENT_USER\Software\Microsoft\IISExpress.
This points to the Web Matrix Config file and not the IIS Express one.
I edited this registry key to point to C:\Users\MyUsername\Documents\IISExpress and now it all works.
I hope this helps.