How to access app configuration from a .dll?

前端 未结 5 1997
执念已碎
执念已碎 2021-02-09 10:42

I recently broke out a part of my winform app in a .dll. Some of the classes in that dll wants fetch/store user settings. The classes just used the VS generated Settings file s

5条回答
  •  北恋
    北恋 (楼主)
    2021-02-09 10:56

    The hosting application should handle the interface to the config file, not the DLL. Either

    1. Pass whatever settings need to be read/modified within the DLL as parameters, or

    2. Pass in a name-value collection of settings that can be modified by the DLL, and save whatever changes are made by the DLL to the collection when control returns to the calling application.

    This is similar in principle to removing a database interface from the business layer of a tiered application and encapsulating it into a data layer.

提交回复
热议问题