Question

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?

Was it helpful?

Solution 2

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>

OTHER TIPS

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.

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="me@google.com" 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)"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top