我正在开发一个C#类库,它需要能够从web.config或app.config文件中读取设置(取决于DLL是从ASP.NET Web应用程序还是Windows窗体应用程序引用).
我发现了
ConfigurationSettings.AppSettings.Get("MySetting")
Run Code Online (Sandbox Code Playgroud)
但是该代码已被Microsoft标记为已弃用.
我读过我应该使用的:
ConfigurationManager.AppSettings["MySetting"]
Run Code Online (Sandbox Code Playgroud)
但是,System.Configuration.ConfigurationManager该类似乎不能从C#类库项目中获得.
有谁知道最好的方法是什么?