Why do people consistently recommend using appConfig instead of using Settings files? (.NET)

后端 未结 7 638
谎友^
谎友^ 2021-01-30 05:30

Very often I see the answer to the question like: \"How should I store settings in my .NET app?\" is to edit the app.config file by manually adding entries to the app.config (or

7条回答
  •  难免孤独
    2021-01-30 06:01

    Two scenarios:

    • A client app which is shipped with configuration settings set to default values. The app provides a UI to modify the settings for a single user or all users.

    Here the "settings" approach wins hands down.

    • An app consisting of several relatively independent assemblies each of which requires a few simple configuration settings. The settings are normally set by an administrator and are not modified by the application once deployed.

    Here "appSettings" can be much simpler to manage. With the "settings" approach, there will be a section for every configurable assembly to be added to the main application's configuration file.

提交回复
热议问题