2015-11-10 68 views
1

最近升級從ASP.NETβ7的到beta8以下這些優秀說明我的應用程序:http://wildermuth.com/2015/10/20/Upgrading_from_ASP_NET_5_Beta_7_to_Beta_8無法啓動升級後的應用程序Asp.net beta8

不幸的是我仍然無法啓動我的應用程序。如果我嘗試使用Kestel(web)啓動,則在調試之前,我會收到500內部服務器錯誤,甚至會在Startup.cs中觸發我的斷點(它仍然會觸發我的斷點)。如果我嘗試在IISExpress推出我得到以下錯誤:

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

運行dnvm列表時選擇了哪個運行時?我想知道它是否意外地指向beta7?您是否還安裝了最新的Web工具以及beta 8安裝? –

+0

像@ armen.shimoon說的,看看你的項目的屬性,看看是否設置了正確的DNX版本。此外,請確保您安裝了Visual Studio的最新版本的DNVM和WebTools。 – Epiplon

+0

我知道我已更新dnvm以使用beta8,並指向項目屬性中的beta8。我也使用.net 4.5.1而不是核心,因爲並不是所有的庫都可以與核心(react.net,signalr)一起工作。我很確定我更新了VS web工具,但會在我能的時候檢查。 –

回答

1

首先,請確保您的項目配置爲以Beta8(項目屬性)運行,並且您的dnvm list顯示您擁有beta8 inst alled。

然後,請確保您沒有AspNetLoader.dllwwwroot\bin中的任何地方。

準備好了嗎?

Microsoft.Dnx.Host.Clr.EntryPoint是ASP.NET 5和IIS之間的Helios填充(AspNetLoader.dll)的入口點。下面是你應該做的,使其工作:

  1. 確保Startup.cs:Configure方法具有以下行頭:app.UseIISPlatformHandler()

  2. 確保你沒有以下環境變量設置:WEBPROJ_ENABLEBETA7RENAMES

  3. 更新global.json爲最新的運行時版本。

這應該讓你去。告訴我你是否有不同的錯誤信息。

這是我的source

相關問題