为什么我随机得到一个"错误使用注册为allowDefinition ='MachineToApplication'&QUOT部分;构建一个MVC项目时? [英] Why do I randomly get a "error to use section registered as allowDefinition='MachineToApplication'" when building an MVC project?

查看:79
本文介绍了为什么我随机得到一个"错误使用注册为allowDefinition ='MachineToApplication'&QUOT部分;构建一个MVC项目时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

部署一个网站时,我看到有关类似的错误在这么几个问题,但我似乎随机得到这个错误时的建筑一个ASP.NET MVC的网站在Visual Studio。执行干净通常修复它,但有什么办法避免这种情况完全?

I have seen a few questions on SO about a similar error when deploying a website, but I seem to randomly get this error when building an ASP.NET MVC website in Visual Studio. Performing a clean usually fixes it, but is there any way to avoid this completely?

这是使用注册为allowDefinition =应用程序级别之外'MachineToApplication'的节是错误的。这个错误可以通过未被配置为在IIS中应用程序的虚拟目录引起的。 D:\\ OBJ \\调试\\包\\ packagetmp \\ web.config中

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. d:...\obj\debug\package\packagetmp\web.config

请注意,它是抱怨根的web.config ,而不是一个来自查看子目录。

Note that it is complaining about the root web.config, not the one from the Views subdirectory.

推荐答案

我假设你正在使用的发布功能。我使用发布到文件目录时收到此错误。

I assume you're using the publish feature. I'm getting this error when using publish to a file directory.

发布应用程序创建应用程序在 \\ OBJ \\调试\\包\\ packagetmp \\ web.config中目录下的临时副本。

Publishing your app creates a temporary copy of your application in the \obj\debug\package\packagetmp\web.config directory.

这web.config中混淆了这认为这是一个应用程序的IDE,但它不是在一个虚拟目录,以便你的错误。

That web.config confuses the IDE which thinks it is an application, but its not in a virtual directory so you get the error.

解决方法:

这是一个简单的解决方法将它添加到pre-build命令:

It's a simple workaround to add this to a pre-build command:

 del "$(ProjectDir)\obj\Debug\Package\PackageTmp\web.config"

失败的解决方法:


  • 更改下',其中包将被创建位置为目录包/发布Web的设置似乎并没有产生效果 - 即使你聪明,并试图把它放在项目的根与外......

  • Changing the directory for 'Location where package will be created' under 'Package/Publish Web' settings doesn't seem to have an effect - even if you get clever and try to put it outside the project root with ......

创建IIS中的实际虚拟目录PackageTmp没有任何修复它!

Creating an actual virtual directory in IIS for 'PackageTmp' didn't fix it either!

连接问题:

<一个href=\"http://connect.microsoft.com/VisualStudio/feedback/details/503254/web-config-in-package-folder-makes-it-impossible-to-compile-debug\">http://connect.microsoft.com/VisualStudio/feedback/details/503254/web-config-in-package-folder-makes-it-impossible-to-compile-debug

我希望他们在RC解决这个问题!

I hope they fix this in the RC!

这篇关于为什么我随机得到一个&QUOT;错误使用注册为allowDefinition ='MachineToApplication'&QUOT部分;构建一个MVC项目时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆