configurationmanager

Changing App.config at Runtime

孤街醉人 提交于 2019-11-26 14:09:31
问题 I'm writing a test WinForms / C# / .NET 3.5 application for the system we're developing and we fell in the need to switch between .config files at runtime, but this is turning out to be a nightmare. Here's the scene: the WinForms application is aimed at testing a WebApp, divided into 5 subsystems. The test process works with messages being sent between the subsystems, and for this process to be successful each subsystem got to have its own .config file. For my Test Application I wrote 5

ConfigurationManager.AppSettings - How to modify and save?

喜夏-厌秋 提交于 2019-11-26 08:07:15
问题 It might sound too trival to ask and I do the same thing as suggested in articles, yet it doesn\'t work as expected. Hope someone can point me to the right direction. I would like to save the usersettings per AppSettings. Once the Winform is closed I trigger this: conf.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); if (ConfigurationManager.AppSettings[\"IntegrateWithPerforce\"] != null) ConfigurationManager.AppSettings[\"IntegrateWithPerforce\"]

What's the difference between the WebConfigurationManager and the ConfigurationManager?

别来无恙 提交于 2019-11-26 06:33:19
问题 What\'s the difference between the WebConfigurationManager and the ConfigurationManager ? When should I use one over the other? UPDATED I just looked at the WebConfigurationManager , and for some reason, you can\'t access the connection strings as you do in the ConfigurationManager (like an array). Can anyone tell me why MS made it like this? It seems to be a pain to get the connection string you need using the WebConfigurationManager . UPDATED AGAIN with CAVEAT! If you don\'t have a

AppSettings get value from .config file

我只是一个虾纸丫 提交于 2019-11-26 05:24:23
问题 I\'m not able to access values in configuration file. Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var clientsFilePath = config.AppSettings.Settings[\"ClientsFilePath\"].Value; // the second line gets a NullReferenceException .config file : <?xml version=\"1.0\" encoding=\"utf-8\" ?> <configuration> <appSettings> <!-- ... --> <add key=\"ClientsFilePath\" value=\"filepath\"/> <!-- ... --> </appSettings> </configuration> Do you have any