Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
633 views
in Technique[技术] by (71.8m points)

asp.net mvc 3 - Web.config transformation: Unrecognized attribute 'xmlns:xdt'. Note that attribute names are case-sensitive

I'm getting this strange intermitent bug in a MVC 3.0 project When I build the project sometimes I get the following error message:

Unrecognized attribute 'xmlns:xdt'. Note that attribute names are case-sensitive.

This is referring to the standard web.config tranformation file (Web.Release.config copied below) There are no other errors or warnings. This is happening in debug mode and release. Sometimes it clears if I clean the solution

BEGIN UPDATE

Found the issue. In the MVC Project file (MyProject.csproj) I had set build views to true

<MvcBuildViews>true</MvcBuildViews>

Once put back to false the above error goes away. I'd like to have the view build as it stops alot of stupid view code errors etc and is a performance enhancement (pages are precompiled instead of jit)

Anyone know what this is causing the error? is this a bug?

END UPDATE

<?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>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I ran into the very same problem. You will find lots of banter out there related to MvcBuildViews and various error conditions. But none seem to mention this particular error. A quick fix that worked for me was to delete the contents of the "obj" directory for the affected web project, then rebuild.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...