2011-11-03 32 views
6

我对此很困惑。当我在发布我的项目时正在开发和使用实时SQL Server时,我想在桌面上使用SQL Server。我正在玩Visual Studio 2010中的转换工具。为什么我在发布时出现“Match Locator”的“无属性”名称?

当我尝试发布我的项目时,我得到“匹配定位器”的“无属性”名称。

我的web.config文件中包含:

<connectionStrings> 
    <add name="EFDbContext" connectionString="Data Source=.\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=db" providerName="System.Data.SqlClient"/> 
</connectionStrings> 

<system.web> 
    <sessionState mode="SQLServer" sqlConnectionString="Server=.\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=ASPState;Application Name=eGov" timeout="20" allowCustomSqlDatabase="true" /> 
</system.web> 

我还在测试它,所以现在,我Web.Release.config文件包含:

<connectionStrings> 
    <add name="EFDbContext" 
     connectionString="Data Source=.\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=db" 
      providerName="System.Data.SqlClient" 
      xdt:Transform="SetAttributes" xdt:Locator="Match(name)" /> 
</connectionStrings> 

<system.web> 
    <compilation xdt:Transform="RemoveAttributes(debug)" /> 
    <sessionState mode="SQLServer" 
     sqlConnectionString="Server=.\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=ASPState;Application Name=app" 
     timeout="20" allowCustomSqlDatabase="true" 
     xdt:Transform="SetAttributes" xdt:Locator="Match(name)" /> 
</system.web> 

什么,我在网上看到的是只会让我更加困惑。任何帮助让我启动和运行?

回答

5

Doh!问题出在sessionState部分。它应该是:

<system.web> 
    <sessionState mode="SQLServer" 
     sqlConnectionString="Server=.\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=ASPState;Application Name=app" 
     timeout="20" allowCustomSqlDatabase="true" 
     xdt:Transform="SetAttributes" xdt:Locator="XPath(configuration/system.web/sessionState)" /> 
</system.web> 
11

xdt:Locator="Match(name)意味着系统将匹配节点使用标签来代替。如果您没有名称属性,则失败。你必须有一些独特的属性来使用这种类型的转换。

2

在Match(name)中使用“name”是典型的配置设置,如下所示。这种情况下的关键是“名称”。

<add name="errorAddress" email="[email protected]" xdt:Transform="SetAttributes" xdt:Locator="Match(name)" /> 

如果您设置的关键是别的东西,那就是你需要的内容:

<add token="UserToken" value="23jkl2klk2j3kja9d8f" xdt:Transform="SetAttributes" xdt:Locator="Match(token)"/> 
相关问题