VS 2015设置正确的目标框架ASP.NET 5 Web项目 [英] VS 2015. Setting right target framework for ASP.NET 5 web project

查看:1424
本文介绍了VS 2015设置正确的目标框架ASP.NET 5 Web项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建在Visual Studio 2015年在项目创建向导我选择,以示对.NET框架4.6,然后从ASP中选择Web应用程序下一个画面的模板创建新的ASP.NET MVC 5项目。 NET 5 preVIEW模板。

I've created new ASP.NET 5 MVC project in Visual Studio 2015. On project creation wizard I've chosen to show the templates for .NET framework 4.6 and then on the next screen selected "Web Application" from ASP.NET 5 Preview Templates.

然而,在创建之后出现,该项目只列出了dnx451和dnxcore50在project.json的框架部分:

However, after creation it appears that the project listed only "dnx451" and "dnxcore50" in "frameworks" section of project.json:

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

我试图改变dnx451到dnx46。该项目已建成非常不错,但是当我试图运行它,我得到了以下错误消息:

I've tried to change "dnx451" to "dnx46". The project has been built well but when I tried to run it, I got the following error message:

目前的运行目标框架不兼容...

The current runtime target framework is not compatible with '...'.

当前运行的目标框架:'DNX,版本= V4.5.1(dnx451)'类型:   CLR体系结构:x86版本:1.0.0-beta5的

Current runtime Target Framework: 'DNX,Version=v4.5.1 (dnx451)' Type: CLR Architecture: x86 Version: 1.0.0-beta5

这怎么可能改变这种目标框架ASP.NET 5项目?

How is it possible to change that "target framework" for ASP.NET 5 project?

下面是我的global.json现在的:

Here is my global.json now:

{
  "projects": [
    "src",
    "test",
    "wrap"
  ],
  "sdk": {
    "version": "1.0.0-beta5",
    "runtime": "clr",
    "architecture": "x86"
  }
}

但它并没有真正的问题是什么列出。我已经尝试了不同的内部版本1.0.0-beta5的和最新的1.0.0-beta6

but it does not really matter what is listed there. I've already tried different builds of 1.0.0-beta5 and the latest 1.0.0-beta6

推荐答案

问题是,DNX知道,你的项目的目标是 dnx46 ,但IIS不:)。因此,IIS开始为.NET 4.5.1(默认情况下),并尝试加载你的项目,这是不符合4.5.1兼容。

The problem is that DNX is aware that your project is targeting dnx46 but IIS is not :). So, IIS is starting as .NET 4.5.1 (by default) and trying to load your project which isn't compatible with 4.5.1.

在VS工具的未来版本中,我们将做检测,但在那之前,事情有点粗糙的Web应用程序要面向.NET版本的上方 4.5.1。现在,我建议只使用 dnx451 在此之前(如果你不依赖于.NET 4.5.2 / 4.6的功能),但我会在下面提供一些指导如何,如果你需要使用4.5.2或更高的今天,使这项工作。

In a future version of the VS Tooling, we're going to do a better job of detecting that but until then, things are a little rough for Web Applications that want to target .NET versions above 4.5.1. For now, I suggest just using dnx451 until then (if you aren't depending on .NET 4.5.2/4.6 functionality), but I'll provide some instructions below on how to make this work today if you need to use 4.5.2 or higher.

注: dnx452 dnx46 完全在控制台应用程序支持,并在使用服务器IIS以外(如红隼或WebListener)。基本上任何你可以启动使用本地 dnx.exe 引导程序适用于 dnx451 dnx46 ,但其他托管环境(IIS,IIS防爆preSS)需要额外的暗示,推出正确的框架。

Note: dnx452 and dnx46 are fully supported in Console Applications and when using servers other than IIS (such as Kestrel or WebListener). Basically anything you can launch using the native dnx.exe bootstrapper works with dnx451 and dnx46 but the other hosting environments (IIS, IIS Express) need additional hints to launch the correct framework.

为使今天的这项工作,你需要一个环境变量 DNX_IIS_RUNTIME_FRAMEWORK 设置为你想要使用的目标框架。您可以在Web应用程序项目属性对话框中做到这一点,调试选项卡上。只要选择IIS前preSS配置文件并添加如下环境变量:

To make this work today, you need to set an environment variable DNX_IIS_RUNTIME_FRAMEWORK to the target framework you want to use. You can do this in the Project Properties page for the web application, on the Debug tab. Just choose the IIS Express profile and add the environment variable as below:

我们会得到这个加入到已知问题的,因为它看起来我们错过了,正如我上面所说的,我们要提高VS默认的经验,所以这是没有必要的。)

We're going to get this added to the Known Issues, because it looks like we missed it, and as I said above, we're going to improve the default experience in VS so this isn't necessary :).

这篇关于VS 2015设置正确的目标框架ASP.NET 5 Web项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆