3

我的Web.Config转换没有被发布 - 我认为这个错误与我得到的这些警告有关。这些Visual Studio警告是什么意思?

使用Visual Studio 2010,我正在玩我的Web.Config/Web.Config.Debug文件。

在我的.Debug文件中,我收到以下警告列出了许多次。

No element in the source document matches '/configuration' 

我认为它会列出它为每个部分存在于.Debug文件。

因此,以下示例Web.Config.Debug文件..将列出两次。 (我猜,第一个是为<connectionStrings>..</>,第二个是为<system.webServer>...</.>

<?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" xdt:SupressWarnings="false"> 

    <connectionStrings> 
     <add name="Foo" connectionString="Server=foo;Database=Foo;uid=foo;password=foo" providerName="System.Data.SqlClient" 
      xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> 
    </connectionStrings> 

    <system.webServer> 
     <httpProtocol> 
      <customHeaders> 
       <clear /> 
       <add name="ETag" value="Dev_IIS" xdt:Transform="SetAttributes" xdt:Locator="Match(name)" /> 
      </customHeaders> 
     </httpProtocol> 
    </system.webServer> 

</configuration> 

任何人的帮助,好吗?

+0

我有同样的问题:http://stackoverflow.com/questions/12593671/why-wont-my-web-config-transforms-work – 2012-09-26 03:21:17

回答

3

我发现this blog post这表明变压器在xmlns =属性上窒息。

我从此改变了我的Web.config文件:

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> 
    <connectionStrings> 
    etc... 

这样:

<configuration> 
    <connectionStrings> 
    etc... 

...你瞧,它的工作原理!

0

我创建了一个新的web应用程序项目(target .net 4.0),将Web.Release.config更改为包含上面粘贴的内容。然后,我去了web.config并添加了以下内容:

<add name="ApplicationServices" 
     connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" 
     providerName="System.Data.SqlClient" /> 
    <add name="Foo" /> <------------------------added this 
    </connectionStrings> 

然后我改变了配置来发布和发布Web应用程序。已发布应用程序包含在web.config中

<add name="ApplicationServices" 
    connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" 
    providerName="System.Data.SqlClient" /> 
<add name="Foo" 
    connectionString="Server=foo;Database=Foo;uid=foo;password=foo" 
    providerName="System.Data.SqlClient" /> <-------this got added 

所以我不知道问题出在哪里,你的情况下。

+0

尝试像我一样创建一个新的项目,看看你是否能够重现问题。 – 2010-06-23 03:50:51

+0

我有这个相同的问题(http://stackoverflow.com/questions/12593671/why-wont-my-web-config-transforms-work)。看起来Web.config中有些东西是转换不喜欢的。我希望我知道... – 2012-09-26 03:24:03

相关问题