Asp.net core 升级到Asp.net beta8后无法启动应用程序
最近,按照以下出色的说明将我的应用程序从ASP.NET beta7升级到beta8: 不幸的是,我仍然无法启动我的应用程序。如果我尝试使用Kestel(web)启动,在调试甚至到达Startup.cs中的断点之前(它仍然到达我的断点),我会收到500个内部服务器错误。如果我尝试在IISExpress中启动,则会出现以下错误:Asp.net core 升级到Asp.net beta8后无法启动应用程序,asp.net-core,Asp.net Core,最近,按照以下出色的说明将我的应用程序从ASP.NET beta7升级到beta8: 不幸的是,我仍然无法启动我的应用程序。如果我尝试使用Kestel(web)启动,在调试甚至到达Startup.cs中的断点之前(它仍然到达我的断点),我会收到500个内部服务器错误。如果我尝试在IISExpress中启动,则会出现以下错误: Could not load type 'Microsoft.Dnx.Host.Clr.EntryPoint' from assembly 'Microsoft.Dnx.
Could not load type 'Microsoft.Dnx.Host.Clr.EntryPoint' from assembly 'Microsoft.Dnx.Host.Clr, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
[TypeLoadException: Could not load type 'Microsoft.Dnx.Host.Clr.EntryPoint' from assembly 'Microsoft.Dnx.Host.Clr, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.]
System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException) +303
[HttpException (0x80004005): Could not load type 'Microsoft.Dnx.Host.Clr.EntryPoint' from assembly 'Microsoft.Dnx.Host.Clr, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9922864
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +90
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +261
我找遍了所有地方,并将其与其他beta8示例进行了比较,但都无济于事。为什么我不能再启动应用程序了?这是我的适用文件-
launchSettings.json
{
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNET_ENV": "development"
},
"sdkVersion": "dnx-clr-win-x86.1.0.0-beta8"
},
"web": {
"commandName": "web",
"launchBrowser": true,
"launchUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNET_ENV": "development"
}
}
}
}
project.json
{
"webroot": "wwwroot",
"userSecretsId": "xxx",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta8",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta8",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta8",
"Microsoft.AspNet.Authentication.Facebook": "1.0.0-beta8",
"Microsoft.AspNet.Authentication.Google": "1.0.0-beta8",
"Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-beta8",
"Microsoft.AspNet.Authentication.Twitter": "1.0.0-beta8",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta8",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-beta8",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-beta8",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta8",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-beta8",
"Microsoft.Dnx.Runtime.Abstractions": "1.0.0-beta8",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta8",
"Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta8",
"Microsoft.Framework.Logging": "1.0.0-beta8",
"Microsoft.Framework.Logging.Console": "1.0.0-beta8",
"StreakMaker.Data": "1.0.0-*",
"StreakMaker.Business": "1.0.0-*",
"React.AspNet": "2.0.0",
"Microsoft.AspNet.SignalR": "2.2.0",
"EntityFramework.SqlServer": "7.0.0-beta8",
"EntityFramework.Core": "7.0.0-beta8",
"EntityFramework.Relational": "7.0.0-beta8",
"Microsoft.AspNet.Mvc": "6.0.0-beta8"
},
"frameworks": {
"dnx451": {
"frameworkAssemblies": {
"System": "4.0.0.0",
"System.Data": "4.0.0.0",
"System.Data.Linq": "4.0.0.0",
"System.Collections": "4.0.0.0",
"System.Threading": "4.0.0.0"
}
}
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
"ef": "EntityFramework.Commands"
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
],
"scripts": {
"postrestore": [ "npm install" ],
"prepare": [ "gulp copy" ]
},
"configurations": {
"development": { },
"production": { },
"staging": { }
}
}
Startup.cs
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Diagnostics.Entity;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Internal;
using Microsoft.Dnx.Runtime;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.Logging;
using Microsoft.Framework.Configuration;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using StreakMaker.Business;
using StreakMaker.Data.Context;
using StreakMaker.Data.Model;
using StreakMaker.Data.Repositories;
using StreakMaker.Data.Repositories.Contracts;
using React.AspNet;
namespace StreakMaker
{
public class Startup
{
private readonly IConfiguration _configuration;
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{
// Setup configuration sources.
var configBuilder = new ConfigurationBuilder()
.SetBasePath(appEnv.ApplicationBasePath)
.AddJsonFile("config.json")
.AddJsonFile($"config.{env.EnvironmentName}.json", true);
if (env.IsEnvironment("development"))
{
// This reads the configuration keys from the secret store.
// For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
configBuilder.AddUserSecrets();
}
configBuilder.AddEnvironmentVariables();
_configuration = configBuilder.Build();
}
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<AppSettings>(_configuration.GetSection("AppSettings"));
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(_configuration["Data:DefaultConnection:ConnectionString"]));
//using (ApplicationDbContext ctx = DbContextActivator.CreateInstance<ApplicationDbContext>(services.BuildServiceProvider()))
//{
// ctx.Database.Migrate();
//}
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
services.AddMvc();
services.AddTransient<IMessageService, MessageService>();
services.AddTransient<IUserRepository, UserRepository>();
services.AddReact();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory)
{
loggerfactory.AddConsole(minLevel: LogLevel.Warning);
if (env.IsEnvironment("Development"))
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseIdentity();
app.UseIISPlatformHandler();
// For more information see http://go.microsoft.com/fwlink/?LinkID=532715
app.UseFacebookAuthentication(options =>
{
options.AppId = _configuration["Authentication:Facebook:AppId"];
options.AppSecret = _configuration["Authentication:Facebook:AppSecret"];
});
app.UseGoogleAuthentication(options =>
{
options.ClientId = _configuration["Authentication:Google:ClientId"];
options.ClientSecret = _configuration["Authentication:Google:ClientSecret"];
});
app.UseMicrosoftAccountAuthentication(options =>
{
options.ClientId = _configuration["Authentication:MicrosoftAccount:ClientId"];
options.ClientSecret = _configuration["Authentication:MicrosoftAccount:ClientSecret"];
});
app.UseTwitterAuthentication(options =>
{
options.ConsumerKey = _configuration["Authentication:Twitter:ConsumerKey"];
options.ConsumerSecret = _configuration["Authentication:Twitter:ConsumerSecret"];
});
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action}/{id?}",
defaults: new { controller = "Home", action = "Dashboard" });
routes.MapRoute(
name: "streak",
template: "{friendlyUrl}",
defaults: new {controller = "Streak", action = "Detail"});
routes.MapRoute(
name: "defaultApi",
template: "api/{controller}/{id?}");
});
app.UseReact(config =>
{
config
.AddScript("~/scripts/Feed/LiveFeedForm.js")
.AddScript("~/scripts/Feed/LiveFeedRow.js")
.AddScript("~/scripts/Feed/LiveFeedList.js")
.AddScript("~/scripts/Common/TextInput.js");
config.SetJsonSerializerSettings(new JsonSerializerSettings()
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
});
});
}
}
}
使用Microsoft.AspNet.Builder;
使用Microsoft.AspNet.Diagnostics.Entity;
使用Microsoft.AspNet.Hosting;
使用Microsoft.AspNet.Identity.EntityFramework;
使用Microsoft.Data.Entity;
使用Microsoft.Data.Entity.Internal;
使用Microsoft.Dnx.Runtime;
使用Microsoft.Framework.DependencyInjection;
使用Microsoft.Framework.Logging;
使用Microsoft.Framework.Configuration;
使用Newtonsoft.Json;
使用Newtonsoft.Json.Serialization;
使用StrokeMaker.Business;
使用StrokeMaker.Data.Context;
使用StrokeMaker.Data.Model;
使用StrokeMaker.Data.Repositories;
使用StrokeMaker.Data.Repositories.Contracts;
使用React.AspNet;
命名空间划线器
{
公营创业
{
专用只读IConfiguration\u配置;
公开启动(IHostingEnvironment env、IApplicationEnvironment appEnv)
{
//设置配置源。
var configBuilder=new ConfigurationBuilder()
.SetBasePath(appEnv.ApplicationBasePath)
.AddJsonFile(“config.json”)
.AddJsonFile($“config.{env.EnvironmentName}.json”,true);
if(环境和环境(“开发”))
{
//这将从机密存储中读取配置密钥。
//有关使用用户机密存储的更多详细信息,请参阅http://go.microsoft.com/fwlink/?LinkID=532709
configBuilder.AddUserSecrets();
}
configBuilder.AddenEnvironmentVariables();
_configuration=configBuilder.Build();
}
//此方法由运行时调用。请使用此方法将服务添加到容器中。
public void配置服务(IServiceCollection服务)
{
services.Configure(_configuration.GetSection(“AppSettings”));
services.AddEntityFramework()
.AddSqlServer()文件
.AddDbContext(选项=>
使用SQLServer(_配置[“数据:默认连接:连接字符串]);
//使用(ApplicationDbContext ctx=DbContextActivator.CreateInstance(services.BuildServiceProvider()))
//{
//ctx.Database.Migrate();
//}
服务.额外性()
.AddEntityFrameworkStores()
.AddDefaultTokenProviders();
services.AddMvc();
services.AddTransient();
services.AddTransient();
services.AddReact();
}
公共void配置(IApplicationBuilder应用程序、IHostingEnvironment环境、iLogger工厂)
{
loggerfactory.AddConsole(minLevel:LogLevel.Warning);
if(环境和环境(“开发”))
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);
}
其他的
{
app.UseExceptionHandler(“/Home/Error”);
}
app.UseStaticFiles();
app.UseIdentity();
app.UseIISPlatformHandler();
//有关更多信息,请参阅http://go.microsoft.com/fwlink/?LinkID=532715
app.UseFacebookAuthentication(选项=>
{
options.AppId=_配置[“身份验证:Facebook:AppId”];
options.AppSecret=_配置[“身份验证:Facebook:AppSecret”];
});
app.UseGoogleAuthentication(选项=>
{
options.ClientId=_配置[“身份验证:Google:ClientId”];
options.ClientSecret=_配置[“身份验证:Google:ClientSecret”];
});
app.UseMicrosoftAccountAuthentication(选项=>
{
options.ClientId=_配置[“身份验证:MicrosoftAccount:ClientId”];
options.ClientSecret=_配置[“身份验证:MicrosoftAccount:ClientSecret”];
});
app.UseTwitterAuthentication(选项=>
{
options.ConsumerKey=_配置[“身份验证:Twitter:ConsumerKey”];
options.ConsumerSecret=_配置[“身份验证:Twitter:ConsumerSecret”];
});
app.UseMvc(路由=>
{
routes.MapRoute(
名称:“默认”,
模板:“{controller}/{action}/{id?}”,
默认值:新建{controller=“Home”,action=“Dashboard”});
routes.MapRoute(
名称:“条纹”,
模板:“{friendlyUrl}”,
默认值:新建{controller=“Streak”,action=“Detail”});
routes.MapRoute(
名称:“defaultApi”,
模板:“api/{controller}/{id?}”);
});
app.UseReact(配置=>
{
配置
.AddScript(“~/scripts/Feed/LiveFeedForm.js”)
.AddScript(“~/scripts/Feed/LiveFeedRow.js”)
.AddScript(“~/scripts/Feed/LiveFeedList.js”)
.AddScript(“~/scripts/Common/TextInput.js”);
config.SetJsonSerializerSettings(新的JsonSerializerSettings()
{
ContractResolver=新CamelCasePropertyNamesCo