简体   繁体   中英

Using app.config both for WCF service/client configuration and for application-specific settings

When I develop a WCF service/client with a configuration file, a new file app.config is created with a section system.serviceModel . Since in my application I should save and load application-specific settings (colors, location of log files, etc), I read documentation about ConfigurationManager class: these settings are also stored in the app.config file within the appSettings section. So, the configuration parameters both for the WCF service/client and for the application-specific settings are loaded from the same file app.config , but from different sections.

Is this the type of use of the app.config file? Or should I use a different file for the application-specific settings? Moreover I did not understand the use of configSections...

The situation you describe is exactly how the app.config file works.

Normally there are different parts in app.config file for things like Connection Strings, WCF configuration settings but also for your own custom settings.

The ConfigurationManager class can be used to access Application specific settings, Connection strings and other configuration data.

ConfigSections are defined on your machine for all standard configuration elements. You can also use ConfigSections to create your own custom sections that can be placed in app.config.

Here is some documentation how to do that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM