首页 新闻 会员 周边 捐助

ASP.NET Core RC2: 'IConfigurationBuilder' does not contain a definition for 'AddJsonFile'

0
悬赏园豆:10 [已解决问题] 解决于 2016-05-17 19:17

用dotnet run运行ASP.NET Core站点时,出现如下的错误:

Startup.cs(24,18): error CS1061: 'IConfigurationBuilder' does not contain a definition for 'AddJsonFile' and no extension method 'AddJsonFile' accepting a first argument of type 'IConfigurationBuilder' could be found (are you missing a using directive or an assembly reference?)

Startup.cs中的对应代码如下:

public Startup(IHostingEnvironment hostingEnv)
{
    IConfigurationBuilder builder = new ConfigurationBuilder()
        .SetBasePath(hostingEnv.ContentRootPath)
        .AddJsonFile("config.json", false);
    Configuration = builder.Build();
}
dudu的主页 dudu | 高人七级 | 园豆:30757
提问于:2016-05-17 19:13
< >
分享
最佳答案
0

在 project.json 文件的 dependencies 中添加如下的配置可解决问题:

"Microsoft.Extensions.Configuration.Json": "1.0.0-*"
dudu | 高人七级 |园豆:30757 | 2016-05-17 19:17
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册