Visual Studio 2013 Settings.settings and Web.config sync Issue

.Net projects can include settings that allow the runtime of an application to be altered based on values present in the Web.config file for the application. Modifying these values doesn’t require the application to be re-compiled when they are changed, which is advantageous in production systems where settings need to be altered without disrupting the environment.

Moving a project from TFS 2008 to TFS 2013 caused some issues with syncing the Web.config with the Settings.settings file. Changes made to the Web.config and then saved usually persist back to the settings file automagically. With a deployed application modifying the Web.config settings was not affecting the application. When the project was deployed the Settings.settings file had a value that wasn’t the same as the Web.config. Strangely, after deploying the application the application ignored changes made to the Web.config.

After a few minutes of head scratching I peeked into the Settings.Designer.cs file and found the setting was not updating when changed in the Web.config. I manually changed the string returned by the setting and saved the file. Like magic, the Web.config started updating the Settings.setting.

Capture

[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("test")]
public string Setting {
   get {
      return ((string)(this["Setting"]));
   }
}

Capture

Capture

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.