Why am I getting a "No attribute 'name' exists for the Match Locator" error when publishing?
Asked Answered
T

3

12

I am so confused on this. I want to use the SQL Server on my desktop when I am developing and using the live SQL Server when I publish my project. I am playing with the transformation stuff in Visual Studio 2010.

I get the "No attribute 'name' exists for the Match Locator" when I try to publish my project.

My Web.config file contains:

<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>

I am still testing it, so for now, my Web.Release.config file contains:

<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>

Anything I am seeing online is only confusing me more. Any help to get me up and running?

Tinsmith answered 3/11, 2011 at 15:49 Comment(0)
T
11

Doh! The problem was in the sessionState section. It should be:

<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>
Tinsmith answered 3/11, 2011 at 16:36 Comment(0)
S
16

xdt:Locator="Match(name) mean that system will match nodes to replace using name tag. If you don't have name attribute then it fails. You must have some unique attribute to use this type of transformation.

Shirline answered 24/8, 2012 at 1:38 Comment(0)
T
11

Doh! The problem was in the sessionState section. It should be:

<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>
Tinsmith answered 3/11, 2011 at 16:36 Comment(0)
S
5

Using "name" in Match(name) is for a typical config setting like the following. The key in this case is "name".

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

If the key in your setting is something else, that is what you need to use:

<add token="UserToken" value="23jkl2klk2j3kja9d8f" xdt:Transform="SetAttributes" xdt:Locator="Match(token)"/>
Sorensen answered 3/8, 2016 at 22:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.