dnx451实际上是指.net 4.5 [英] dnx451 actually means .net 4.5

查看:37
本文介绍了dnx451实际上是指.net 4.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Visual Studio 2015 RC创建了两个项目

I created two projects using Visual Studio 2015 RC

  1. 一个类库 MyLib ,其目标框架为 .NET Framework 4.5.1
  2. 一个ASP.NET 5项目 MyWebApp ,该项目在 project.json 中引用 MyLib :

  1. a class library MyLib which its target framework is .NET Framework 4.5.1
  2. an ASP.NET 5 project MyWebApp which references MyLib in project.json:

框架":{"dnx451":{依赖关系":{"Lib01":"1.0.0- *"}},}

"frameworks": { "dnx451": { "dependencies": { "Lib01": "1.0.0-*" } }, }

当我尝试构建 MyWebApp 时,出现警告:

When I trying to build MyWebApp, an warning occurs:

MSB3274:无法解析主要引用"C:\ MyWebApp \ src \ MyLib \ bin \ Debug \ MyLib.dll",因为它是针对".NETFramework,Version = v4.5.1"框架构建的.该版本比当前目标框架".NETFramework,Version = v4.5"更高.

MSB3274: The primary reference "C:\MyWebApp\src\MyLib\bin\Debug\MyLib.dll" could not be resolved because it was built against the ".NETFramework,Version=v4.5.1" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.5".

如果将 MyLib 的目标框架更改为4.5,警告将消失.

The warning will disappear if I change the target framework of MyLib to 4.5.

似乎 MyWebApp 是针对.net Framework 4.5而非4.5.1的?如何使 MyWebApp 引用针对.net 4.5.1的库?

It seems like the MyWebApp is targeting .net framework 4.5 rather than 4.5.1? How to make MyWebApp references a library targeting .net 4.5.1?

推荐答案

此警告似乎意义不大.即使将Web项目的.net版本设置为大于库的.NET版本,它仍然可见.

This warning doesn't seem to mean much. It it still visible even if .net version of web project is set to be greater than library's e.g.

"net46": {                
  "dependencies": {
    "Lib01": "1.0.0-*"
  }
}

另一个有趣的事情是,可以针对.NET Framework 4.6(最新)构建库,并且仍可以在dnx451项目中构建/运行并使用类(我已经将只读队列作为4.6的IReadOnlyCollection从lib传递到了web应用程序.)

Another interesting thing that it's possible to have library build against .NET Framework 4.6 (latest) and still build/run and use classes from within dnx451 project (I've passed readonly Queue available only in 4.6 as IReadOnlyCollection from lib to web application).

据我所知,.net 4.5.1尚未引入对API的更改,并且很难测试4.5和4.5.1之间的差异

Besides that as far as I know .net 4.5.1 has not introduced changes for API and it's not very easy to test difference between 4.5 and 4.5.1

最后,如果您想摆脱警告,可以创建vNext类型类库(Package),然后从ASP.NET 5应用程序中引用它,以便您的类库可以使用与Web应用程序相同的dnx451.

And finally if you want to get rid of warning you can create vNext type class library (Package) and then refer it from ASP.NET 5 Application, so your class library could use dnx451 the same as web app.

这篇关于dnx451实际上是指.net 4.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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