c# - 如何摆脱错误“无效的 appsettings.json 文件?
问题描述
如果我启动我的程序,我会收到如下错误:“ Invalid appsettings.json 文件”
我需要这个文件来访问 Graph API。
如果我写了这个文件的本地目录,它就可以工作。
代码如下:
var config = new ConfigurationBuilder()
.SetBasePath(System.IO.Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", false, true)
.Build();
appsettings.json:
{
"tenantId": "",
"applicationId": "",
"applicationSecret": "",
"redirectUri": "https://localhost"
}
解决方案
I just ran the output of the CurrentDirectory and it was a wrong folder. Then I wrote a little Replace Code that replaced the wrong folder with the right one.
推荐阅读
- spring-batch - 自定义 ItemWriter 以像 CompositeWriter 一样工作以将数据写入 db 和 xml
- bash - 为什么 extglob "+(*/)A" 不像 "find -name A" 那样工作?
- android - Android UI 测试无法解析以下活动:意图
- javascript - 为 VueJS 应用程序实现 manifest.json 文件以设置条件
- powershell - 将某种类型的文件从一个文件夹移动到另一个文件夹
- java - 从 Java Arraylist 中删除
- react-native - 按钮上的 KeyboardAwareScrollView
- android - 使存储库在 Clean Architecture 的域层中不可见
- android - 是否可以避免应用程序关闭的活动?
- php - 自定义帖子查看计数器 WordPress