Why does not the debugging change when the app. config file is written in winform?

Source: Internet
Author: User

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 ..

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.