Martin
Martin

Reputation: 40593

Error 'IConfigurationProvider' claims it is defined in 'Microsoft.Framework.Configuration.Abstractions'

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();
    }
}

Upvotes: 1

Views: 1181

Answers (2)

Bogdan Kanteruk
Bogdan Kanteruk

Reputation: 318

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

Upvotes: 2

cygnim
cygnim

Reputation: 2035

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.

Upvotes: 1

Related Questions