Why am I getting a "No Attribute" error message for a Match Locator error when publishing?

I am so confused by this. I want to use SQL Server on my desktop when I design and use Live SQL Server when publishing my project. I play with conversion things in Visual Studio 2010.

I get the name “No Attribute” for “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> 

Everything that I see on the Internet only confuses me. Any help to get me up and running?

+6
source share
3 answers

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> 
+5
source

xdt:Locator="Match(name) means that the system will replace nodes using the name tag. If you do not have a name attribute, it does not work. You must have a unique attribute to use this type of transformation.

+11
source

Using "name" in Match (name) for a typical configuration parameter, such as 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 setup is something else, this is what you need to use:

 <add token="UserToken" value="23jkl2klk2j3kja9d8f" xdt:Transform="SetAttributes" xdt:Locator="Match(token)"/> 
+2
source

Source: https://habr.com/ru/post/900714/


All Articles