【问题标题】:Reference manager is empty in vs 2017 .net core class library projectvs 2017 .net核心类库项目中的引用管理器为空
【发布时间】:2019-07-06 01:27:50
【问题描述】:

我正在尝试添加对 System.Configuration.dll 程序集的引用。
我正在使用 .Net Core,这可以在我的 .csproj 文件中看到:

<TargetFramework>netcoreapp2.2</TargetFramework>

(我的项目的输出类型设置为Class Library。)

为此,在解决方案资源管理器中,我右键单击我的项目的Dependencies,然后单击Add Reference...。问题是打开的引用管理器是空的,没有我可以添加引用的程序集。

但是,如果不引用该程序集,我可以编写以下行而不会出现任何构建错误:

using System.Configuration;

第一个问题:如果没有我引用该程序集,上述行怎么可能成功构建?

如果我尝试使用 ConfigurationManager 类从 app.config 文件中读取数据(如 here 所述),我会收到一条错误消息:

CS0103  The name 'ConfigurationManager' does not exist in the current context

问题二:我能做些什么来解决这个错误?我的代码或项目有什么问题?

我的情况与this question 不同,这不是那个问题的重复。

【问题讨论】:

    标签: c# .net-core visual-studio-2017 configurationmanager


    【解决方案1】:

    Add Reference 供您本地参考。您需要使用 Nuget 包管理器 来包含引用。

    最重要的是 .Net Core 不使用 .Net Framework 包,其中 ConfigurationManager 是 .Net Framework 包。

    您需要将 .Net Core.Net Standard 库与 .Net Core

    一起使用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-18
      • 2019-01-08
      • 2018-11-11
      相关资源
      最近更新 更多