System.Threading.Tasks和System.Runtime中的任务冲突

时间:2017-01-01 13:23:23

标签: c# asp.net-core .net-core

我在asp.net核心中有一个中间件,工作正常,但现在它给出了以下错误

  

类型'任务'存在于System.Threading.Tasks,Version = 4.0.10.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'和' System.Runtime,Version = 4.2.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a' ERP..NETCoreApp,版本= 1.1版

我尝试了别名和绝对引用,但它没有用。

enter image description here

这是Project.json

{
  "dependencies": {
    "AutoMapper": "5.2.0",
    "Microsoft.AspNetCore.Diagnostics": "1.1.0",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.1.0",
    "Microsoft.AspNetCore.Mvc": "1.1.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
    "Microsoft.AspNetCore.Session": "1.1.0",
    "Microsoft.AspNetCore.StaticFiles": "1.1.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
    "Microsoft.Extensions.Configuration.Json": "1.1.0",
    "Microsoft.Extensions.Logging.Console": "1.1.0",
    "Microsoft.Extensions.Logging.Debug": "1.2.0-preview1-23015",
    "Microsoft.NETCore.App": {
      "version": "1.1",
      "type": "platform"
    }
  },

  "tools": {
  },

  "frameworks": {
    "netcoreapp1.1": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "Areas/**/*.cshtml",
      "wwwroot",
      "web.config"
    ]
  },

  "scripts": {
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  },
  "userSecretsId": "aspnet-ERP-20161109085850"
}

1 个答案:

答案 0 :(得分:0)

我能够解决Debug包版本的这一变化。

"Microsoft.Extensions.Logging.Debug": "1.2.0-preview1-23015",

"Microsoft.Extensions.Logging.Debug": "1.1.0",

并在Invoke方法签名中进行更改

public Task Invoke(HttpContext httpContext)

public async Task Invoke(HttpContext httpContext)