我有这段代码:
using Microsoft.Extensions.Configuration;
using System;
using System.IO;
using System.Threading.Tasks;
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json");
var config = builder.Build();
var authenticationConfig = new AuthenticationConfig();
config.Bind(authenticationConfig);
我得到:
Severity Code Description Project File Line Suppression State
Error CS1061 'IConfigurationRoot' does not contain a definition for 'Bind' and no accessible extension method 'Bind' accepting a first argument of type 'IConfigurationRoot' could be found (are you missing a using directive or an assembly reference?) SandboxSecurityToken C:\xxx\Program.cs 35 Active
我已经导入了Microsoft.Extensions.Configuration(请参阅:使用Microsoft.Extensions.Configuration)。知道可能缺少什么吗?谢谢!