Asp.Net Core 中无法使用 ConfigurationManager.AppSettings

贵有恒,何必三更起、五更眠、最无益,只怕一日曝、十日寒。这篇文章主要讲述Asp.Net Core 中无法使用 ConfigurationManager.AppSettings相关的知识,希望能为你提供帮助。
.net core 无法使用 ConfigurationManager.AppSettings【Asp.Net Core 中无法使用 ConfigurationManager.AppSettings】刚刚接触.net core ,准备把之前的一些技术常用工具先移植到.net Standard上面来, 方便以后使用,结果用到ConfigurationManager 的  AppSettings 就出现各种问题
首先是 
错误 CS0012 类型“NameValueCollection”在未引用的程序集中定义。必须添加对程序集“System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”的引用。

Asp.Net Core 中无法使用 ConfigurationManager.AppSettings

文章图片

考虑到.net Core 和 .net Standard 的跨平台性,System.dll 应该就不是获取的系统本地的,so 去Nuget 找找,然后过果断找到这个
Microsoft.NETCore.Portable.Compatiblity,其中包含一些系统级类库
Asp.Net Core 中无法使用 ConfigurationManager.AppSettings

文章图片

 
可是结果还是一样,然后继续百度各种资料,结果是。。。没有结果
无奈只有翻*墙求助谷歌,结果让我找到这个
No ConfigurationManager in ASP.NET Core,没错.net core 不支持了! 
参考资料
https://www.danylkoweb.com/Blog/no-configurationmanager-in-aspnet-core-GC
https://stackoverflow.com/questions/40551232/configurationmanager-appsettings-generates-compile-time-error-on-net-standard-1
Core 中获取AppSettings 的方式之一
https://colinmackay.scot/2016/07/03/application-configuration-in-net-core-part-1/

    推荐阅读