假設程序集引用'System.Runtime,Version = 4.0.20.0'

asp.net-core-1.0 entity-framework-core visual-studio-2015

我的所有代碼中都有以下警告:

Visual Studio 2015社區版中的警告

這是我的project.json:

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "build"
    },
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Razor.Tools": {
    "version": "1.0.0-preview2-final",
    "type": "build"
    },
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
    "Microsoft.EntityFrameworkCore": "1.0.1",
    "System.Runtime": "4.1.0"
  },
  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
      "dotnet5.6",
      "portable-net45+win8"
      ]
    }
  },
  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp    deploy-node-libraries", "gulp sass", "gulp min" ]
   }
}

如您所見,我包含了“System.Runtime”:“4.1.0”,就像之前版本中建議的依賴項一樣,但是它不起作用。我的環境是:Windows 7 Pro - Service Pack 1 - Core I7,Visual Studio 2015社區版 - Asp.Net核心項目模板

該項目實際編譯,但我調用的所有行和EntityFramework核心的類都加下劃線,IISExpress無法為頁面提供服務。

一般承認的答案

我有同樣的問題,這是我如何修復我的:

嘗試運行:

nuget.exe locals all -clear

在nuget cli中清除你的本地緩存。

然後在cli中輸入:

dotnet restore

然後在項目json中添加運行時並刪除"type": "build"

"Microsoft.NETCore.App": {
  "version": "1.0.0",
  "type": "build" <= remove that line
},

我還將版本設置為1.0.1。我也安裝了SDK的1.0.0-preview2-003131並相應地設置了我的global.json文件:

"sdk": {
    "version": "1.0.0-preview2-003131"
}

在我的3個項目的每個project.json中,我有

  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "version": "1.0.1"
        }
      }
    }
  },
  "runtimes": {
    "win10-x64": {}
  }

我的“Microsoft.AspNetCore.Server.Kestrel”版本是“1.0.1”,因此是“Microsoft.AspNetCore.Mvc”(1.0.1)

如果仍然無效,請嘗試重新安裝最新的SDK (1.0.0-preview2-003131)並檢查您是否:

  • Visual Studio 2015 Update 3 .NET Core 1.0.1
  • VS 2015工具預覽2

有關此更新的更多信息,請參見此處

希望這可以幫助。



Related

許可下: CC-BY-SA with attribution
不隸屬於 Stack Overflow
這個KB合法嗎? 是的,了解原因
許可下: CC-BY-SA with attribution
不隸屬於 Stack Overflow
這個KB合法嗎? 是的,了解原因