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

后端 未结 4 1362
春和景丽
春和景丽 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:07

    For ApplicationSettings you should use:

    [YourNamespace].Properties.Settings.Default.[YourSettingName]
    

    This provides a strongly typed reference to your setting and returns the default value if one is not defined in the web.config file. For AppSettings you should use:

    System.Web.Configuration.WebConfigurationManager.AppSettings
    

提交回复
热议问题