命名空间中不存在'Logging' Microsoft.扩展



所以我在文件的第1行有以下行:

using Microsoft.Extensions.Logging;

构建时抛出

CS0234 C# The type or namespace name 'Logging' does not exist in the namespace (are you missing an assembly reference?)

已尝试四处搜索,但无法找到任何解决方案或原因。项目设置为在.net core 2.0中构建,已经下载并安装了.NET Core 2.0 SDK (v2.1.202),但是错误仍然存在。

已尝试更改构建版本为2.1,3.0也没有帮助。

使用。net 6.0,我能够复制:

error CS0234: The type or namespace name 'Logging' does not exist in the namespace 'Microsoft.Extensions' (are you missing an assembly reference?)

引用Microsoft.Extensions.Logging;:

using Microsoft.Extensions.Logging;

从命令行安装任何扩展包,除了日志记录:

$ dotnet add package Microsoft.Extensions.Primitives

我可以通过添加Microsoft.Extensions.Logging包来消除您的错误:

$ dotnet add package Microsoft.Extensions.Logging

相关内容

最新更新