1

I updated my ASP.NET 5 project from Beta 7 to Beta 8 and I am getting the following error message.

Error CS7069: Reference to type 'IConfigurationProvider' claims it is defined in 'Microsoft.Framework.Configuration.Abstractions', but it could not be found

Any idea what has changed? Below is the I am using.

public class Startup
{
    public IConfigurationRoot Configuration { get; set; }

    public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
    {
        this.Configuration = new ConfigurationBuilder() <-- ERROR
            .SetBasePath(appEnv.ApplicationBasePath)
            .AddJsonFile("config.json")
            .AddJsonFile($"config.{env.EnvironmentName}.json", optional: true)
            .AddEnvironmentVariables()
            .Build();
    }
}
Martin
  • 39,309
  • 62
  • 192
  • 278

2 Answers2

2

I've added next dependencies in my project.json:

"Microsoft.Framework.Configuration": "1.0.0-beta8",
"Microsoft.Framework.Configuration.Abstractions": "1.0.0-beta8",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta8"

and changed code of creating ConfigurationBuilder in Startup.cs to:

var builder = new ConfigurationBuilder()
    .SetBasePath(appEnv.ApplicationBasePath)
    .AddJsonFile("config.json")
    .AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);

In my case it works

1

The ConfigurationBuilder reference has been moved out of Microsoft.Configuration.Abstractions in beta8 and is now locoated in Microsoft.Framework.Configuration.Abstractions.

Update any namespace (using) statements which reference Microsoft.Configuration.Abstractions to Microsoft.Framework.Configuration.Abstractions in your Startup.cs file and verify that it is listed in your dependencies in project.json.

cygnim
  • 1,985
  • 2
  • 16
  • 22