K
Keith
Hello,
Using VS2005, I have a Windows Forms app that uses the default
Settings.settings file. When the app is built, the properly-named
app.settings file is built into the output directory, and it contains the
correct application-level settings. Controls in the app that are bound to
settings in the app.config display the correct values. When values are
changed by hand in the app.settings file these new values are correctly
displayed when the app is run. In code, the following calls correctly
retrieve settings values:
global::<namespace>.Properties.Settings[<settingname>]
Properties.Settings[<settingname>]
Properties.Settings.<settingname>
However, the following functions always return null values:
ConfigurationManager.AppSettings[<settingname>]
ConfigurationSettings.AppSettings[<settingname>]
ConfigurationManager.OpenExeConfiguration(Assembly.GetEntryAssembly().Location).AppSettings.Settings[<settingname>]
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).AppSettings.Settings[<settingname>]
ExeConfigurationFileMap efm = new ExeConfigurationFileMap();
efm.ConfigFileName = Assembly.GetEntryAssembly().Location + ".config";
ConfigurationManager.OpenMappedExeConfiguration(efm,
ConfigurationUserLevel.None).AppSettings.Settings[<settingname>]
All returned Configuration objects have the correct filepath and
HasFile==true.
I can use the Properties.Settings syntax when I'm in the right class, but I
need to access these settings from a satellite assembly and don't want to
pass around references if I don't have to.
Can anyone tell me what I'm doing wrong, or why these function calls can't
manage to find my settings?
Keith
Using VS2005, I have a Windows Forms app that uses the default
Settings.settings file. When the app is built, the properly-named
app.settings file is built into the output directory, and it contains the
correct application-level settings. Controls in the app that are bound to
settings in the app.config display the correct values. When values are
changed by hand in the app.settings file these new values are correctly
displayed when the app is run. In code, the following calls correctly
retrieve settings values:
global::<namespace>.Properties.Settings[<settingname>]
Properties.Settings[<settingname>]
Properties.Settings.<settingname>
However, the following functions always return null values:
ConfigurationManager.AppSettings[<settingname>]
ConfigurationSettings.AppSettings[<settingname>]
ConfigurationManager.OpenExeConfiguration(Assembly.GetEntryAssembly().Location).AppSettings.Settings[<settingname>]
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).AppSettings.Settings[<settingname>]
ExeConfigurationFileMap efm = new ExeConfigurationFileMap();
efm.ConfigFileName = Assembly.GetEntryAssembly().Location + ".config";
ConfigurationManager.OpenMappedExeConfiguration(efm,
ConfigurationUserLevel.None).AppSettings.Settings[<settingname>]
All returned Configuration objects have the correct filepath and
HasFile==true.
I can use the Properties.Settings syntax when I'm in the right class, but I
need to access these settings from a satellite assembly and don't want to
pass around references if I don't have to.
Can anyone tell me what I'm doing wrong, or why these function calls can't
manage to find my settings?
Keith