I want to downgrade a .net library from framework version 4.5 to .net 4.0.
I have several libs installed using nuget:
I do the following:
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
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.
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 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.
In your case, as the .NET 4.5 already been installed, so The 4.5 update completely replaces the .NET 4.0 runtime.
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.
So in order to downgrade your project from 4.5 to 4.0, I agree with you, you need to:
Hanselman and Rick had explained it very well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With