この例外は、ホスト変数の作成時にProgram.csに現れたばかりで、Program.cs内の何も更新しないため、なぜそれが表示されるのかわかりません。 私はVSを再起動しようとしましたが、ソリューション内のすべてのプロジェクトでbinとobjを削除しました。Program.cs内のSystem.MissingMethodException
例外:見つからない
方法: 'System.Collections.Generic.Dictionary`2 Microsoft.Extensions.Configuration.IConfigurationBuilder.get_Properties()'。
Program.csの:
using Microsoft.AspNetCore.Hosting;
using System.IO;
namespace LC.Smokers
{
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.UseApplicationInsights()
.Build();
host.Run();
}
}
}
Startup.cs:
public class Startup
{
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables();
Configuration = builder.Build();
}
public IConfigurationRoot Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddLocalization(options => options.ResourcesPath = "Resources");
services.AddSingleton<IActionContextAccessor, Models.ActionContextAccessor>();
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddSingleton<AppHelper>();
services.AddTransient<SessionHelper>();
services.AddDistributedMemoryCache();
services.AddSession(options =>
{
options.Cookie.Name = ".Smokers.Session";
options.IdleTimeout = TimeSpan.FromHours(2);
});
services.AddMvc()
.AddViewLocalization(Microsoft.AspNetCore.Mvc.Razor.LanguageViewLocationExpanderFormat.Suffix)
.AddDataAnnotationsLocalization();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Shop/Error");
}
List<CultureInfo> supportedCultures = new List<CultureInfo>
{
new CultureInfo("no-NB"),
new CultureInfo("en-US")
};
app.UseRequestLocalization(new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("no-NB"),
SupportedCultures = supportedCultures,
SupportedUICultures = supportedCultures
});
app.UseSession();
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Shop}/{action=Index}/{id?}");
});
}
}
[SignalR Core for ASP.netコア2.0は、何を試しても動作しません](https://stackoverflow.com/questions/45497003/signalr-core-for-asp-net-core-2- – mjwills