【发布时间】:2014-03-21 00:30:09
【问题描述】:
我想将 .net 库从框架版本 4.5 降级到 .net 4.0。
我使用 nuget 安装了几个库:
- Microsoft.AspNet.WebApi.Client 及其依赖项:
- Newtonsoft.Json
- System.Net.Http(Microsoft .Net 4 HTTP 客户端库)
我会做以下事情:
在我的解决方案中每个项目的设置中,我将目标框架设置为 4.0。之后我尝试重建我的解决方案,但由于错误
The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?),当然没有成功,对于 HTTP 客户端库也是如此使用 nuget ui 管理器我删除了依赖项并尝试重新安装。但是有错误
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 的库替换这些库并重写部分代码?
【问题讨论】:
-
如果您的引用大于 .Net4.0 则不能将其添加到 .Net4.0 项目中。
-
感谢您的回复。对不起,我没看懂你的问题。我有几个项目的解决方案。截至目前,所有 packages.configs 中的所有项目都有
targetFramework="net45"。但我想让这个解决方案的项目可用于.net 4.0。我的问题是:“实现这一目标的最简单方法是什么?”。