.net - 您的项目未引用 ".NETFramework,Version=v4.5"框架。

我正在使用 VS 2015。

Your project is not referencing the ".NETFramework,Version=4.5" framework. Add a reference to ".NETFramework,Version=4.5" in the "frameworks" section of your project.json, and then re-run NuGet restore.

在添加到我的 MVC 层后不久,我在数据访问和业务逻辑层上收到此错误。在那之前一切都很好,但我不知道是什么触发了这个错误。这是我的 project.json:

{
  "version": "1.0.0-*",
  "description": "foo bar Class Library",
  "authors": [ "foo bar" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",

  "frameworks": {
    "net451": { },
    "dotnet5.4": {
      "dependencies": {
        "Microsoft.CSharp": "4.0.1-beta-23516",
        "System.Collections": "4.0.11-beta-23516",
        "System.Linq": "4.0.1-beta-23516",
        "System.Runtime": "4.0.21-beta-23516",
        "System.Threading": "4.0.11-beta-23516"
      }
    }
  }
}

这是我尝试过的:

  1. 将“dotnet5.4”替换为“net451”(并删除),如 this answer 中所示.

结果是同样的错误。

  1. 将“dotnet5.4”替换为“net45”并保留“net451”。这会导致一个新错误:

Your project.json doesn't have a runtimes section. You should add '"runtimes": { "win":{} }' to your project.json and then re-run NuGet restore.

我尝试按照此错误的建议进行操作并添加

"runtimes": {
    "win":  {}
  },

这给了我这个错误,我似乎无法超越:

Your project.json doesn't list 'win' as a targeted runtime. You should add '"win": {}' inside your "runtimes" section in your project.json, and then re-run NuGet restore.

我已经添加了“win”,这开始让人感觉像是一条红鲱鱼。我在做什么直接改变 project.json,NuGet 不是在处理这个吗?

最佳答案

我遇到了同样的问题,最后我不仅要删除 binobj 文件夹的内容,还要删除 .vs 解决方案的目录。

关于.net - 您的项目未引用 ".NETFramework,Version=v4.5"框架。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36190601/

相关文章:

json - JSON中的反序列化和序列化是什么?

python - 如何从 Python 中的文件/流中懒惰地读取多个 JSON 值?

javascript - 在 promise 链上使用 setTimeout

arrays - 数组可以是顶级 JSON 文本吗?

c# - Protocol Buffer 与 JSON 或 BSON

python - JSON中的单引号和双引号

python - JSON 值错误 : Expecting property name: line

c# - 从 .NET 控制台调用 JSON WebService 的最佳方式

jquery - Rails 无法正确解码来自 jQuery 的 JSON(数组变成带有整数键的散列

python - python中的json.dump()和json.dumps()有什么区别?