I was using the < character in my password and when the app.config was updated the < was changed to <
This obviously caused a problem logging into the database.
Hi Greg,
Thanks for getting in touch. This is by design as the attribute values in the app.config
file should be XML escaped. I did a quick test and <
was read out as <
. My App.Config
looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Password" value="My<Pass"/>
</appSettings>
<connectionStrings>
<add name="db" connectionString="Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=My<Pass"/>
</connectionStrings>
</configuration>
And my test program like this:
static void Main(string[] args)
{
Console.WriteLine(ConfigurationManager.AppSettings["Password"]);
Console.WriteLine(ConfigurationManager.ConnectionStrings["Db"].ConnectionString);
Console.ReadLine();
}
The output:
My<Pass
Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=My<Pass
Please let me know if I have misunderstood your question, or you are still having problems.
Robert W