Getting configuration settings from web.config/app.config using class library

后端 未结 4 1369
春和景丽
春和景丽 2020-12-09 18:48

Configuration settings in 3.5 is driving me nuts... Help! ;)

I have a class library (Named ADI), that needs some configuration settings from the project using it (li

4条回答
  •  情书的邮戳
    2020-12-09 19:16

    If you're not after structured settings, the appSettings section just takes key-value pairs:

    
      
      
    
    

    This will enable you to access them via the AppSettings dictionary:

    ConfigurationManager.AppSettings["ADIImageVariantsRoot"]
    

    As you would expect.

    Alternatively, if you need more structure to your configuration (i.e. more than just strings, or a collection of settings), you can look into using a configuration section of your own, using a ConfigurationSection, and its relevant parts.

提交回复
热议问题