错误'IConfigurationProvider'声称它在'Microsoft.Framework.Configuration.Abstractions'中定义

时间:2015-10-16 22:18:33

标签: c# asp.net asp.net-core asp.net-core-mvc

我将我的ASP.NET 5项目从Beta 7更新为Beta 8,我收到以下错误消息。

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

知道发生了什么变化吗?以下是我正在使用的。

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

2 个答案:

答案 0 :(得分:2)

我已在project.json中添加了下一个依赖项:

CustomerCompany.getByCustomerAccount({customer_account_id: customer_account_id + '.json'}, function(data){
    console.log(data);
    //$scope.list_of_delegates.push(data);
}); 

并将Startup.cs中创建ConfigurationBuilder的代码更改为:

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

就我而言,它有效

答案 1 :(得分:1)

{8}中的ConfigurationBuilder引用已移出Microsoft.Configuration.Abstractions,现在位于Microsoft.Framework.Configuration.Abstractions

更新Startup.cs文件中引用Microsoft.Configuration.AbstractionsMicrosoft.Framework.Configuration.Abstractions的任何命名空间(using)语句,并验证它是否在project.json中的依赖项中列出。