Spurious MachineToApplication Error With VS2010 Deployment
Often when I’m building my MVC 2 application using Visual Studio 2010, I get the following error:
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.
On the internet, this error seems to be related to having a nested web.config in your application. I do have such a thing, but it’s just the one that came out of the MVC 2 project item template and I haven’t touched it.
In my case, this error in my case doesn’t seem to have anything to do with a nested web.config. This error only started to happen when I began using the web site deployment features in VS2010 which by itself, rocks (see Scott Hanselman’s “Web Deployment Made Awesome: If You’re Using XCopy, You’re Doing It Wrong” for details).
If it happens to you and it doesn’t seem to make any sense, you can try to fix it with a Build Clean command. If you’re using to previous versions of Visual Studio, you’ll be surprised, like I was, not to find a Clean option in sparse the Build menu. Instead, you can only get to it by right-clicking on your project in the Solution Explorer and choosing Clean.
Doing that, however, seems to make the error go away. I don’t think that’s a problem with my app; I think that’s a problem with VS2010.