How to load a separate Application Settings file dynamically and merge with current settings?

Well, this works: using System; using System.Configuration; using System.IO; using System.Linq; using System.Xml.Linq; using System.Xml.XPath; public static class SettingsIO { internal static void Import(string settingsFilePath) { if (!File.Exists(settingsFilePath)) { throw new FileNotFoundException(); } var appSettings = Properties.Settings.Default; try { var config = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.PerUserRoamingAndLocal); string appSettingsXmlName = Properties.Settings.Default.Context[“GroupName”].ToString(); // returns “MyApplication.Properties.Settings”; // Open settings file … Read more

WCF Error – The maximum message size quota for incoming messages (65536) has been exceeded [duplicate]

That would be because you didn’t specify on the server which binding to use. Let’s take a look at your server config: Under <bindings> you are creating a binding configuration for <basicHttpBinding>, and you are naming it name=”basicHttpBinding”. Also, your endpoint name is <endpoint name=”basicHttpBinding” …> and its binding is binding=”basicHttpBinding”. However, it’s not referring … Read more

PowerShell App.Config

Cross-referencing with this thread, which helped me with the same question: Subsonic Access To App.Config Connection Strings From Referenced DLL in Powershell Script I added the following to my script, before invoking the DLL that needs config settings, where $configpath is the location of the file I want to load: [appdomain]::CurrentDomain.SetData(“APP_CONFIG_FILE”, $configpath) Add-Type -AssemblyName System.Configuration … Read more

Registry vs. INI file for storing user configurable application settings [closed]

Pros of config file: Easy to do. Don’t need to know any Windows API calls. You just need to know the file I/O interface of your programming language. Portable. If you port your application to another OS, you don’t need to change your settings format. User-editable. The user can edit the config file outside of … Read more

Is it .yaml or .yml?

The nature and even existence of file extensions is platform-dependent (some obscure platforms don’t even have them, remember) — in other systems they’re only conventional (UNIX and its ilk), while in still others they have definite semantics and in some cases specific limits on length or character content (Windows, etc.). Since the maintainers have asked … Read more

Changing App.config at Runtime

I understand this is quite an old thread, but I could not get the listed methods to work. Here is a simpler version of the UpdateAppSettings method (using .NET 4.0): private void UpdateAppSettings(string theKey, string theValue) { Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); if (ConfigurationManager.AppSettings.AllKeys.Contains(theKey)) { configuration.AppSettings.Settings[theKey].Value = theValue; } configuration.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection(“appSettings”); } Pretty readable and avoids … Read more

How to enable configSource attribute for Custom Configuration Section in .NET?

The actual file, must be placed relative to the project output folder (by default “\bin\debug” or “bin\Release” Also, The file in your project tree, look at the properties of the file, and make sure the “Copy to Output Directory” setting is set to “Copy Always” or “Copy if Newer” EDIT: make sure the separate config … Read more

Read custom configuration file in C# (Framework 4.0)

// Map the roaming configuration file. This // enables the application to access // the configuration file using the // System.Configuration.Configuration class ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap(); configFileMap.ExeConfigFilename = roamingConfig.FilePath; // Get the mapped configuration file. Configuration config = ConfigurationManager.OpenMappedExeConfiguration( configFileMap, ConfigurationUserLevel.None); from http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.aspx