在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?)
在project.json中添加Microsoft.Framework.ConfigurationModel.Json的引用
{ "dependencies":{ "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-*" } }