When is an app.config created, when an app.exe.config and what is the difference

前端 未结 1 1232
耶瑟儿~
耶瑟儿~ 2020-12-14 07:26

We have created a WinForms application and store some configurations via the ConfigurationManager class. In order to store the information I use

Configurati         


        
相关标签:
1条回答
  • 2020-12-14 07:37

    The "appname.exe.config" is automatically created for you when you compile your application. This is the file that should be distributed to your end users (along with the exe file, of course). The settings you set in appname.config is transferred over to appname.exe.config. They are essentially the same files. The reason appname.config exists is because when the executable is run, it's config file is simple the executable's name with a .config suffix. However, if the executable's name changed, you would have to change the name of the exe.config file manually. Therefore, by automatically renaming at compile time, the app.config can change it's name to newappname.exe.config file and the CLR will still pick it up. You'll probably find that the appname.exe.config file is created in the bin directory. I hope that's clear :) The links below may explain it in slightly more depth.

    There's a good explanation here. Another good read is on CodePlex.

    0 讨论(0)
提交回复
热议问题