使用注册为allowDefinition ='MachineToApplication'的部分是错误的

Nea*_*aox 16 publish web-config visual-studio-2012

当我尝试发布我的Web应用程序时,我正在使用visual studio 2012我收到以下错误:

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
Run Code Online (Sandbox Code Playgroud)

以下是输出窗口的内容:

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 ==========
Run Code Online (Sandbox Code Playgroud)

如果有人能够阐明为什么会发生这种情况以及如何解决这个问题,那就太棒了.

我已经尝试过清理和重建(它重建得很好)我试过删除bin,obj并移动临时输出目录 - 仍然是错误仍然存​​在.

小智 26

这是web.config发布过程创建的额外内容的问题.将鼠标悬停在选项卡上web.config,您将看到额外文件的位置,然后您可以将其清除.甚至可能是针对不同的配置,但它仍然会引发错误(例如,调试与发布)可能类似于<app>\obj\Release\Package\PackageTmp\web.config.

删除它,你应该很高兴去.可能会在以后的出版物上重复出现.


小智 9

这似乎是一个非常常见的问题,如果这是由Visual Studio中的Web发布功能创建的额外web.config引起的,则错误消息绝对没有帮助.

我能够通过强制我的ASP.NET应用程序项目在每次构建后清除obj目录来克服.

将以下内容添加到构建后事件中,然后运行构建后事件:"始终"

rmdir /S /Q "$(ProjectDir)\obj"
Run Code Online (Sandbox Code Playgroud)


Chr*_*int 0

web.config 中的一项设置存在问题。该错误可能会让您了解该位置。