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

问题描述 投票:0回答:1

所以我在文件的第 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?)

曾尝试四处寻找但无法找到任何解决方案或原因。项目设置为build in

.net core 2.0
,已下载安装
.NET Core 2.0 SDK (v2.1.202)
,但错误依旧

尝试将构建版本更改为

2.1
3.0
也没有帮助。

c# .net-core
1个回答
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

© www.soinside.com 2019 - 2024. All rights reserved.