Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

It is an error to use a section registered as allowDefinition='MachineToApplication'

I'm using visual studio 2012 when I try to publish my web application I get the following error:

Error   1   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.  E:\Temp\BUILD\Debug\AspnetCompileMerge\Source\bin\web.config    24  0   Pixelate

Here is the contents of the output window:

1>------ Build started: Project: Pixelate, Configuration: Debug Any CPU ------
1>  No way to resolve conflict between "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac, Retargetable=Yes" and "System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e". Choosing "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac, Retargetable=Yes" arbitrarily.
1>  No way to resolve conflict between "System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" and "System.ServiceModel.Web, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e". Choosing "System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" arbitrarily.
1>  Pixelate -> [...]\bin\TwistedPixel.Pixelate.dll
1>  '[...]\bin'
1>  CMD.EXE was started with the above path as the current directory.
1>  UNC paths are not supported.  Defaulting to Windows directory.
2>------ Publish started: Project: Pixelate, Configuration: Debug Any CPU ------
2>Connecting to [...]...
2>Transformed Web.config using [...]\Web.Debug.config into E:\Temp\BUILD\Debug\TransformWebConfig\transformed\Web.config.
2>Transformed[...]\Web.config using [...]\bin\Web.Debug.config into E:\Temp\BUILD\Debug\TransformWebConfig\transformed\bin\Web.config.
2>Copying all files to temporary location below for package/publish:
2>E:\Temp\BUILD\Debug\AspnetCompileMerge\Source.
2>C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v / -p E:\Temp\BUILD\Debug\AspnetCompileMerge\Source -c -d E:\Temp\BUILD\Debug\AspnetCompileMerge\TempBuildDir 
2>E:\Temp\BUILD\Debug\AspnetCompileMerge\Source\bin\web.config(24,0): Error ASPCONFIG: 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.
2>
========== Build: 1 succeeded, 0 failed, 2 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========

If anyone can shed some light onto why this is happening and how to fix it, that would be great.

I have tried cleaning and rebuilding (it rebuilds fine) I have tried deleting the bin, obj and have move the temp output directory - still the error persists.

like image 756
Neaox Avatar asked Oct 19 '12 08:10

Neaox


3 Answers

This is a problem with an extra web.config being created by the Publish process. Hover over the tab for the web.config and you'll see the extra file's location that you can then clean out. Might even be for a different configuration but it still throws the error (e.g. Debug vs. Release) Probably in something like <app>\obj\Release\Package\PackageTmp\web.config.

Delete it and you should be good to go. Might recur on later publishes though.

like image 164
Mark Thormann Avatar answered Oct 09 '22 01:10

Mark Thormann


This seems to be a pretty common issue and the error message is absolutely no help when this is caused by the extra web.config being created by the Web Publishing feature in Visual Studio.

I was able to overcome by forcing my ASP.NET application project to purge the obj directory after every build.

Add the following to your post-build event, and run the post-build event: 'Always'

rmdir /S /Q "$(ProjectDir)\obj"
like image 10
cathode Avatar answered Oct 09 '22 03:10

cathode


Clean solution whilst your solution is configured in Release mode.

Clean solution whilst your solution is configured in Debug mode.

Build whilst your solution is configured in Debug mode.

like image 1
Anup Shetty Avatar answered Oct 09 '22 03:10

Anup Shetty



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!