首页 新闻 搜索 专区 学院

ASP.NET 5:'Configuration' does not contain a definition for 'AddJsonFile'

0
悬赏园豆:20 [已解决问题] 解决于 2015-07-04 19:16

在Startup.cs添加了如下的代码:

public class Startup
{
    public Startup(IHostingEnvironment env)
    {
        Configuration = new Configuration()
            .AddJsonFile("config.json")
            .AddEnvironmentVariables();
    }

    public IConfiguration Configuration { get; set; }
}

用dnx运行时出现下面的错误:

error CS1061: 'Configuration' does not contain a definition for 'AddJsonFile' and no extension method 'AddJsonFile' accepting a first argument of type 'Configuration' could be found (are you missing a using directive or an assembly reference?)
dudu的主页 dudu | 高人七级 | 园豆:36406
提问于:2015-07-04 19:11
< >
分享
最佳答案
0

在project.json中添加Microsoft.Framework.ConfigurationModel.Json的引用

{
    "dependencies":{
        "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-*"
    }
}
dudu | 高人七级 |园豆:36406 | 2015-07-04 19:15
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册