3

出于某种原因,我无法使用 DNX 和 Kestrel 运行一个简单的、开箱即用的 ASP.NET 5 / Core 1.0 Web 应用程序。运行后dnx web我不断收到错误:

Error: Unable to load application or execute command 'Microsoft.AspNet.Server.Kestrel'. Available commands: web, ef.

我的项目.json:

{
  "version": "1.0.0-*",
  "userSecretsId": "aspnet5-WebApplication-635604fe-13b8-4779-8e12-35ec067b73ae",
  "compilationOptions": {
    "emitEntryPoint": true
  },
  "tooling": {
    "defaultNamespace": "WebApplication"
  },

  "dependencies": {
    "EntityFramework.Commands": "7.0.0-rc1-final",
    "EntityFramework.Sqlite": "7.0.0-rc1-final",
    "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
    "Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
    "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
    "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
    "Microsoft.Dnx.Runtime":"1.0.0-rc1-final",
    "Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final"
  },

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel",
    "ef": "EntityFramework.Commands"
  },

  "frameworks": {
    "dnx451": { },
    "dnxcore50": { }
  },

  "exclude": [
    "wwwroot",
    "node_modules",
    "bower_components"
  ],
  "publishExclude": [
    "**.user",
    "**.vspscc"
  ],
  "scripts": {
    "prepublish": [
      "npm install",
      "bower install",
      "gulp clean",
      "gulp min"
    ]
  }
}

是的,我以前跑过dnu restore。我安装了这些运行时:

dnx-clr-win-x64.1.0.0-rc1-update1
dnx-clr-win-x64.1.0.0-rc1-update2
dnx-clr-win-x86.1.0.0-rc1-update1
dnx-clr-win-x86.1.0.0-rc1-update2
dnx-coreclr-win-x64.1.0.0-rc1-update2

我真的希望有人知道这个问题可能来自哪里。

更新

看来我在解决依赖项和程序集绑定方面遇到了问题。每当我运行dnu build它时,它构建得很好,我可以看到所有 nuget 包依赖项都在 C:\users\*****\.dnx\packages 中解析/恢复。

但是,在运行时dnx web,我不断收到我提到的错误。我启用了 FusionLog,似乎早期的 nuget 包依赖关系现在没有解决。我不断收到这样的错误:

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNet.Hosting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.AspNet.Hosting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
   at WebApplication.Startup.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
   at Microsoft.Dnx.ApplicationHost.Program.<>c__DisplayClass3_0.<ExecuteMain>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Users\*****\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-update2\bin\dnx.exe
--- A detailed error log follows.

=== Pre-bind state information ===
LOG: DisplayName = Microsoft.AspNet.Hosting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
 (Fully-specified)
LOG: Appbase = file:///C:/Users/*****/.dnx/runtimes/dnx-clr-win-x86.1.0.0-rc1-update2/bin/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.AspNet.Hosting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
LOG: Fusion is hosted. Check host about this assembly.
LOG: Try host assembly store with assembly microsoft.aspnet.hosting, version=1.0.0.0, culture=neutral, publickeytoken=adb9793829ddae60, processorarchitecture=x86.
LOG: Try host assembly store with assembly microsoft.aspnet.hosting, version=1.0.0.0, culture=neutral, publickeytoken=adb9793829ddae60, processorarchitecture=msil.
LOG: Try host assembly store with assembly microsoft.aspnet.hosting, version=1.0.0.0, culture=neutral, publickeytoken=adb9793829ddae60.
WRN: Host assembly store does not contain this assembly.
LOG: Attempting download of new URL file:///C:/Users/*****/.dnx/runtimes/dnx-clr-win-x86.1.0.0-rc1-update2/bin/Microsoft.AspNet.Hosting.DLL.
LOG: Attempting download of new URL file:///C:/Users/*****/.dnx/runtimes/dnx-clr-win-x86.1.0.0-rc1-update2/bin/Microsoft.AspNet.Hosting/Microsoft.AspNet.Hosting.DLL.
LOG: Attempting download of new URL file:///C:/Users/*****/.dnx/runtimes/dnx-clr-win-x86.1.0.0-rc1-update2/bin/Microsoft.AspNet.Hosting.EXE.
LOG: Attempting download of new URL file:///C:/Users/*****/.dnx/runtimes/dnx-clr-win-x86.1.0.0-rc1-update2/bin/Microsoft.AspNet.Hosting/Microsoft.AspNet.Hosting.EXE.

所以我现在知道问题出在哪里了。如果我暂时将所需的 dll 复制到/C:/Users/*****/.dnx/runtimes/dnx-clr-win-x86.1.0.0-rc1-update2/bin它似乎可以解决,但这不是解决方案。

更新 2

似乎问题出在 clr 运行时。每当我通过输入 cmd 使用 coreclr 时dnvm use 1.0.0-rc1-update1 -a x86 -r coreclrdnx web应用程序运行得很好。

我尝试重新安装 clr,为 x64 和 x86 安装 update1 和 update2,但错误仍然存​​在。只有 coreclr 似乎工作。有什么想法吗?

4

0 回答 0