我在 MVC 3.0 项目中遇到这个奇怪的间歇性错误当我构建项目时,有时我会收到以下错误消息:
无法识别的属性“xmlns:xdt”。请注意,属性名称区分大小写。
这是指标准的 web.config 转换文件(Web.Release.config 复制在下面)没有其他错误或警告。这发生在调试模式和发布中。有时,如果我清理解决方案,它就会清除
开始更新
发现问题。在 MVC 项目文件(MyProject.csproj)中,我将构建视图设置为 true
<MvcBuildViews>true</MvcBuildViews>
一旦放回假,上述错误就会消失。我想要构建视图,因为它可以阻止很多愚蠢的视图代码错误等,并且是一种性能增强(页面是预编译而不是 jit)
任何人都知道这是导致错误的原因吗?这是一个错误吗?
结束更新
<?xml version="1.0"?>
<!-- For more information on using Web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an atrribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your Web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>