1

RC1 プロジェクトを RC2 に移行しようとしています。私のプロジェクトは正常に復元および構築されています。しかし、 dotnet run と入力すると、 Exception: Could not find method: 'Microsoft.Extensions.Configuration.IConfigurationBuilder Microsoft.Extensions.Configuration.IConfigurationBuilder.Add(Microsoft.Extensions.Configuration.IConfigurationProvider)' が発生しました。

そして、これは私の Startup コンストラクターです:

public Startup(IHostingEnvironment env)
    {
        Log.Logger = new LoggerConfiguration().MinimumLevel.Debug().
            WriteTo.RollingFile(@"C:\log\file-{Date}.txt",
                outputTemplate:
                    "{Timestamp: yyyy-MM-dd HH:mm:ss.fff zzz} {Level}:{EventId} [{SourceContext}] {Message}{NewLine}{Exception}")
            .CreateLogger();

        var builder = new ConfigurationBuilder() //<-error in this line
            .SetBasePath(env.ContentRootPath)
            .AddJsonFile("appsettings.json")
            .AddJsonFile("config.json")
            .AddEnvironmentVariables();

        Configuration = builder.Build();
    }

そして、これは私のproject.jsonです:

    {
     "version": "1.0.0-*",
     "buildOptions": {
     "emitEntryPoint": true
  },
  "runtimeOptions": {
    "gcServer": false,
    "gcConcurrent": true
  },
  "dependencies": {
    "bootstrap": "4.0.0-alpha2",
    "BootstrapNotifications": "0.3.2",
    "bootstrap-notify": "0.1.0",
    "Dapper": "1.50.0-rc2",
    "Microsoft.AspNet.Antiforgery": "1.0.0-rc1-final",
    "Microsoft.AspNet.Http.Extensions": "1.0.0-rc1-final",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Http.Extensions": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.JsonPatch": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Mvc.Formatters.Json": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Mvc.Razor": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Mvc.ViewFeatures": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.WebListener": "0.1.0-rc2-final",
    "Microsoft.AspNetCore.Session": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final",
    "Microsoft.Exchange.WebServices": "2.2.0",
    "Microsoft.Extensions.Configuration.Abstractions": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.Binder": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
    "Microsoft.Extensions.Primitives": "1.0.0-rc2-final",
    "Microsoft.Framework.Configuration.EnvironmentVariables": "1.0.0-beta6",
    "Microsoft.Framework.ConfigurationModel": "1.0.0-beta4",
    "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta4",
    "Microsoft.Framework.Logging": "1.0.0-beta8",
    "Microsoft.NetCore.App": {
      "type": "platform",
      "version": "1.0.0-rc2-16357"
    },
    "Microsoft.NETCore.Platforms": "1.0.1-rc2-24027",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc2-final",
    "Newtonsoft.Json": "8.0.3",
    "OctoPack": "3.0.60",
    "PagedList": "1.17.0",
    "PagedList.Mvc": "4.5.0",
    "Serilog.Extensions.Logging": "1.0.0-rc2-10104",
    "Serilog.Framework.Logging": "1.0.0-rc1-final-10083",
    "Serilog.Sinks.Literate": "2.0.0-rc-25",
    "Serilog.Sinks.RollingFile": "2.0.0-rc-703",
    "System.Console": "4.0.0-rc2-24027",
    "System.Linq": "4.1.0-rc2-24027",
    "System.Linq.Dynamic": "1.0.6",
    "System.Runtime.Extensions": "4.1.0-rc2-24027",
    "System.Xml.XmlDocument": "4.0.1-rc2-24027"
  },
  "exclude": [
    "wwwroot",
    "node_modules"
  ],
  "frameworks": {
    "net46": {
      "imports": [
        "dnxcore50",
        "portable-net45+win8"
      ],
      "dependencies": {
      }
    }
  },
  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "appsettings.json",
      "web.config"
    ]
  }
}
4

2 に答える 2

4

一致しないバージョンのパッケージを使用しています。具体的には、例外は次の行によって発生します。

"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc1-final",

他のパッケージは RC2 で、これは RC1 です。これは、これAddEnvironmentVariables()が RC1 バージョンであることを意味し、RC2 で変更された依存関係からメソッドを呼び出そうとします。

これを修正するには、RC2 パッケージのみを使用してください。

于 2016-05-31T14:24:54.247 に答える