If you publish an ASP.Net (MVC) application in VS 2010, you need to define a Target Location in the Publish… dialog.
VS then builds and publishes. Another manual build will result in the error message
Error 3 It is an error to use a section registered as allowDefinition=’MachineToApplication’ beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
For better entertainment, the file name that causes the error is displayed as “web.config” in the Error List window.
Right-click and select Copy will fill the clipboard with the real file path, which is
which is a relict of the publishing process.
The solution is to delete everything from the obj\Debug and obj\Release directories (depending on your build configuration) and build again.
Executing “Clean Solution” or “Clean Project” also solves the problem.