Using appsettings in the DAL layer

◇◆丶佛笑我妖孽 提交于 2019-12-03 16:08:47

You need to use config.AppSettings.Settings["DataStorageLocation"]. See the MSDN documentation for a sample.

Alternatively, and IMHO better, you could use System.Configuration.ConfigurationManager.AppSettings[name] to access the AppSettings of the host application. This is probably more flexible than your technique, as it will also work if your DAL assembly is, for example, hosted in a service tier on IIS. Accessing configuration information from the host application's configuration file directly in this way is perfectly accceptable, and generally better than passing configuration information down through the layers.

The AppSettings are accessible to any assembly loaded by the calling process, so you will have no problems accessing them with any assembly you load.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!