【问题标题】:ConfigurationManager could not be found找不到配置管理器
【发布时间】:2026-02-18 23:30:01
【问题描述】:

我有一个基于前端 react 和后端 .net MVC 的网站

我想在ConfigurationManager 中获取 AppSettings 方法,但 VS 告诉我,System.Configuration 中没有 ConfigurationManager 类型名称

我在System.Configuration 上有一个参考。我尝试了其他问题中的所有内容,但它不起作用。

如果我尝试使用 System.Web.Configuration.WebConfigurationManager.AppSettings 方法访问 AppSettings,它会给我一个错误,即 Configuration 没有类型名称或命名空间

Full error from VS

有人可以帮我解决这个问题吗?

【问题讨论】:

  • 我相信您需要 System.Configuration.ConfigurationManager.AppSettings 而不是 System.Web.Configuration.WebConfigurationManager.AppSettings
  • 我试过了,但是我无法访问System.Configuration.ConfigurationManager.AppSettings的功能,因为它找不到System.Configuration.ConfigurationManager

标签: .net configurationmanager system.configuration webconfigurationmanager


【解决方案1】:

哇哦……

使用 nuGet 我必须搜索 system.configuration 然后我可以安装 System.Configuration.ConfigurationManager

现在可以正常使用了

【讨论】: