2017-01-01 74 views
0

衝突我在asp.net核心,做工精細一箇中間件,但現在它在下面給出錯誤任務System.Threading.Tasks和System.Runtime

「任務」在這兩種存在型「系統.Threading.Tasks,Version = 4.0.10.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'和'System.Runtime,Version = 4.2.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'ERP..NETCoreApp,Version = v1.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" 
} 
+0

請複製你的方法的代碼。我無法看到它,因爲彈出信息 – NicoRiff

+0

發佈你的project.json,你已經搞亂了你的引用。我懷疑你已經將框架部分中的完整.NET Framework程序集添加到了.NET核心應用程序/ .NET標準庫中,或者您的某個依賴關係還會添加 – Tseng

+0

@Tseng project.json。 – Ahmar

回答

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) 
+0

除非在方法中使用'await',否則不需要添加'async',只需要創建一個異步狀態機 – Tseng

+0

我已經在這個方法中等待。 – Ahmar