[英]downgrade .net 4.5 application to 4.0
I want to downgrade a .net library from framework version 4.5 to .net 4.0. 我想将.net库从框架版本4.5降级到.net 4.0。
I have several libs installed using nuget: 我使用nuget安装了几个库:
I do the following : 我做以下事情 :
In settings of each project in my solution I set target framework to 4.0 . 在我的解决方案中的每个项目的设置中,我将目标框架设置为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 在它之后我尝试重建我的解决方案但当然没有成功因为错误The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
,HTTP Client libs也是如此
Using nuget ui manager I removed dependencies and tried to reinstall . 使用nuget ui manager我删除了依赖项并尝试重新安装 。 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.
但是有一个错误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.
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.
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替换这些库并重写代码的某些部分?
.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是.NET 4.0的就地升级,这意味着CLR是相同的,但添加了新的库以及错误修复和性能改进,并且两者都指向.NET CLR 4。
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.5,因此4.5更新完全取代了.NET 4.0运行时。
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. 即使您将项目更改为.NET 4.0,内部使用的库仍然指向4.5但仅限于可用于4.0的库,但行为可能与您在纯.NET 4中的预期不同。
So in order to downgrade your project from 4.5 to 4.0, I agree with you, you need to: 因此,为了将您的项目从4.5降级到4.0,我同意您的意见,您需要:
Hanselman and Rick had explained it very well. 汉塞尔曼和瑞克解释得非常好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.