无法确定合适的 运行 版本到 运行

Couldn't determine an appropriate version of runtime to run

我刚刚升级到 beta4。我的代码在没有 errors/warnings 的情况下成功编译,但我无法启动我在 IIS Express 中托管的 Web api(通过点击 F5)。我收到以下错误:

Couldn't determine an appropriate version of runtime to run. See http://go.microsoft.com/fwlink/?LinkId=517742 for more information.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Couldn't determine an appropriate version of runtime to run. See http://go.microsoft.com/fwlink/?LinkId=517742 for more information.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidOperationException: Couldn't determine an appropriate version of runtime to run. See http://go.microsoft.com/fwlink/?LinkId=517742 for more information.] System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException) +303

[HttpException (0x80004005): Couldn't determine an appropriate version of runtime to run. See http://go.microsoft.com/fwlink/?LinkId=517742 for more information.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9940016 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +261

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.57.0

这是 dnvm list 的输出:

C:\src\web-api-skeleton [master]> dnvm list

Active Version Runtime Architecture Location Alias


  • 1.0.0-beta4 clr x64 C:\Users\dpeden.dnx\runtimes default
    1.0.0-beta4 clr x86 C:\Users\dpeden.dnx\runtimes
    1.0.0-beta4 coreclr x64 C:\Users\dpeden.dnx\runtimes
    1.0.0-beta4 coreclr x86 C:\Users\dpeden.dnx\runtimes
    1.0.0-beta4-11566 clr x86 C:\Users\dpeden.dnx\runtimes

我也尝试过显式设置运行时(Use Specific Runtime 在项目属性的“调试”选项卡上),但似乎没有任何效果。

在从 VS 2015 CTP 6 和 beta3 升级到 VS 2015 RC 和 beta4 之前,我没有遇到这个问题。

如何解决?

谢谢。

Cross reference on ASP.NET Forums

原来是一道简单的题。看完https://github.com/aspnet/Announcements/issues/3,我发现我把aspnet50改成了dnx46,而应该是dnx451。对我的所有 project.json 文件进行更改后,我的问题就解决了。

片段:

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