Aspnet_compiler as post-build event encounters IIS error in empty MVC3 application

I fire up aspnet_compiler as a post-build event using the following command:

aspnet_compiler.exe -v / -p \ 

I get this error while compiling:

An error occurred while using a section registered as allowDefinition = 'MachineToApplication' that is higher than the application level. This error can be caused by the fact that the virtual directory is not configured as an application in IIS.

I read several other StackOverflow about this and tried the following:

  • I looked at the roaming web.config files - there are none, except for two, that are included in the standard MVC application (in the main MVC directory and in the views directory).
  • Added application in IIS. It didn’t matter.
  • I tried to work with IIS Express instead of the development server - no difference.

Any thoughts on what could be causing this?

+4
source share
1 answer

I think this is actually a Visual Studio bug. When I saw this error, I usually:

  • Close Visual Studio.
  • Delete the bin and obj folders of the project.
  • Delete any other folder where the confusing web.config might be (for example, the backup subfolder inside the project.)
  • Launch Visual Studio.
  • Open the solution and compile it again.
+1
source

All Articles