In case anyone else has been having trouble with this, Microsoft have made breaking changes to this part of the framework on 16 August 2015. You must import the right versions of the dependencies and switch across to the new way of building up configuration.
My config includes:
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.Framework.Runtime": "1.0.0-*",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta7",
"Microsoft.AspNet.Mvc": "6.0.0-beta7",
"Microsoft.Framework.Configuration": "1.0.0-beta7",
"Microsoft.Framework.Configuration.Json": "1.0.0-*"
},
...
}
This code, inspired by this question might go some way to helping you:
using System;
using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Messenger.Services;
using Microsoft.Framework.Configuration;
using Microsoft.Dnx.Runtime;
using Microsoft.AspNet.Hosting;
namespace Messenger
{
public class Startup
{
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{
var configurationBuilder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
.AddJsonFile("config.json")
.AddEnvironmentVariables();
Configuration = configurationBuilder.Build();
}
public IConfiguration Configuration { get; set; }
}
...
}
Hope it helps.