降级.NET 4.5的应用程序4.0 [英] downgrade .net 4.5 application to 4.0

查看:1267
本文介绍了降级.NET 4.5的应用程序4.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从降级Framework版本4.5 .NET库到.NET 4.0。

I want to downgrade a .net library from framework version 4.5 to .net 4.0.

我有几个库使用的NuGet安装:

  • Microsoft.AspNet.WebApi.Client和它的依赖关系:
  • Newtonsoft.Json
  • System.Net.Http(微软的.Net 4 HTTP客户端库)

我做了以下

  • 在每个项目的设置,我的解决方案我设定的目标框架,4.0 的。当然不会,因为错误的成功,它后,我试图重建我的解决办法,但的类型或命名空间名称Newtonsoft'找不到(是否缺少using指令或程序集引用?),同为HTTP客户端库

  • In settings of each project in my solution I set target framework to 4.0 . After it I tried to rebuild my solution but of course without success because of error The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?), the same for HTTP Client libs

使用的NuGet UI管理我删除依赖关系,并试图重新安装的。但有一个错误无法安装包'Microsoft.AspNet.WebApi.Client 5.1.1。您正在尝试安装此包到该目标的.NETFramework,版本= V4.0的一个项目,但 包不包含任何程序集引用或与该框架兼容的内容文件。欲了解更多信息,请联系包的作者。

Using nuget ui manager I removed dependencies and tried to reinstall. But there is an error Could not install package 'Microsoft.AspNet.WebApi.Client 5.1.1'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

我的问题是:我可以降级这个项目,或者我应该替换这些库的一些支持.NET 4.0和改写code一些地方

My question is: can I downgrade this project or I should replace these libs with some that support .net 4 and rewrite some parts of code?

推荐答案

.NET 4.5就地升级.NET 4.0,这意味着CLR是相同的,但新的库添加和bug修复和性能的改进,以及两者的顷 指向.NET CLR 4。

.NET 4.5 is an in-place upgrade for .NET 4.0 which means that the CLR is the same but new libraries are added as well as bug fixes and performance improvements, and both of the are point to .NET CLR 4.

在你的情况下,作为.NET 4.5已经安装了,所以4.5的更新完全取代了.NET 4.0运行时。

In your case, as the .NET 4.5 already been installed, so The 4.5 update completely replaces the .NET 4.0 runtime.

即使你的项目更改到.NET 4.0,内部使用的库仍然指向4.5,但仅限于提供者为4.0,但行为可能会有所不同,你 预计在纯.NET 4。

Even if you change your project to .NET 4.0, the library used inside is still point to 4.5 but restricted to those available for 4.0, but behaviors may be different as what you expect in pure .NET 4.

因此​​,为了您的项目降级为4.5〜4.0,我同意你的观点,你需要:

So in order to downgrade your project from 4.5 to 4.0, I agree with you, you need to:

  1. 重新安装.NET框架只.NET 4中(如果你不要求.NET 4.5了)
  2. 变更项目指向.NET 4
  3. 改写的code某些部分不支持通过.NET 4 (例如,在你的情况下,Microsoft.AspNet.WebApi.Client 5.1.1配WebApi2在      .NET 4.5,你需要将它降级到使用方式,.NET 4提供 )
  1. Re-install your .NET framework to .NET 4 only (if you don't require .NET 4.5 any more)
  2. change project to point to .NET 4
  3. rewrite some part of the code which is not supported by .NET 4 (e.g. in your case, the Microsoft.AspNet.WebApi.Client 5.1.1 is come with WebApi2 in .NET 4.5, and you need to downgrade it to using the way as .NET 4 provided )

<一个href="http://www.hanselman.com/blog/NETVersioningAndMultiTargetingNET45IsAnInplaceUpgradeToNET40.aspx">Hanselman和<一href="http://weblog.west-wind.com/posts/2012/Mar/13/NET-45-is-an-inplace-replacement-for-NET-40">Rick已经解释得很好。

这篇关于降级.NET 4.5的应用程序4.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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