Environment vs2010
It's easy to read. Basically, all users use configurationmanager. receivettings [""]. tostring ()
Writing config is not very common.CodeAs follows:
|
/// <Summary> /// Modify the value of an item in the configuration file /// </Summary> /// <Param name = "key"> specify the key of ettings </param> /// <Param name = "value"> the value of the deleteworkflow </param> Public static void setconfig (string key, string value) { Configuration Config = configurationmanager. openexeconfiguration (configurationuserlevel. None ); If (config. appsettings. settings [Key]! = NULL) Config. etettings. settings [Key]. value = value; Else Config. appsettings. settings. Add (Key, value ); Config. Save (configurationsavemode. modified ); Configurationmanager. refreshsection ("receivettings "); } |
|
|
However, during debugging, I found that the content in APP. config under the project has not changed. Without debugging (find the debug file under the project), run the EXE file and find that the app. config file has changed.
Cause:
During debugging (Press F5), the compiler overwrites the EXE, DLL, and config files under debug. Then execute the exefile and vshost.exe (this file is used for debugging ). In this case, the config content under debug is changed.
The app. config file in the project has not changed... Therefore, the config under debug is overwritten by App. config during next debugging .. So we can see what I mentioned above ..