gpt4 book ai didi

c# - .NET 6.0 ConfigurationBuilder 缺少 AddJsonFile 方法

转载 作者:行者123 更新时间:2023-12-03 08:01:13 28 4
gpt4 key购买 nike

var builder = new ConfigurationBuilder().AddJsonFile(somepath);

错误消息状态

ConfigurationBuilder does not contain a definition for AddJSONFile.

如果我查看“依赖项/包”文件夹,则会显示以下内容:

Microsoft.Extensions.Configurations(6.0.1)

该类的此版本中似乎缺少方法。

最佳答案

安装Microsoft.Extensions.Configuration.Json nuget 包。

我还建议考虑Microsoft.Extensions.Hosting nuget 通过 generic hosting 处理了很多此类问题(并且取决于上述包):

A host is an object that encapsulates an app's resources and lifetime functionality, such as:

  • Dependency injection (DI)
  • Logging
  • Configuration
  • App shutdown
  • IHostedService implementations

关于c# - .NET 6.0 ConfigurationBuilder 缺少 AddJsonFile 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74127366/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com