在 Startup.cs 中添加 AddOptions 时出错

Error while adding AddOptions in Startup.cs

我正在尝试实现此 link 中提到的选项模式 - https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration#options-example

当我在 Startup.cs

的 ConfigureServices 中添加这两行时
    public void ConfigureServices(IServiceCollection services)
    {
        // Setup options with DI
        services.AddOptions();

        services.Configure<AppSettingsModel>(Configuration);

我收到以下调用在以下方法或属性之间不明确的错误- call is ambiguous error screenshot

我完整的project.json是这样的-

{
  "dependencies": {
    "Glimpse": "2.0.0-beta1",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Identity": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0",
    "Microsoft.AspNetCore.Mvc.WebApiCompatShim": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.Extensions.Configuration.CommandLine": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
    "Microsoft.EntityFrameworkCore.SqlServer.Design": {
      "version": "1.0.0",
      "type": "build"
    },
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    }
  },

  "tools": {
    "BundlerMinifier.Core": "2.0.238",
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
    "Microsoft.Extensions.SecretManager.Tools": "1.0.0-preview2-final",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": [
        "portable-net45+win8"
      ]
    }
  },

  "frameworks": {
    "net461": { }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "web.config",
      "Views",
      "Areas/**/Views",
      "appsettings.json"
    ]
  },

  "scripts": {
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

我的环境是 - VS2015 update3、.net core SDK 1.0.0 和 preview2 工具

我的项目模板是 - ASP.NET 核心应用程序(.NET 框架 4.6.1)

有人可以指导我吗?

您必须从依赖项中删除 Glimpse。正如您在 Microsoft.AspNet.FileProviders.Embedded 上的 NuGet it depends on Glimpse.Server and Glimpse.Server depends 上看到的那样,这是一个过时的 ASP.NET 核心包,直到 RC1 版本。这些包现在被命名为 Microsoft.AspNetCore.*

这会导致同时获取(旧程序集和新程序集)并且编译器无法确定使用哪一个。混合版本总是很糟糕。