2016-08-31 79 views
0

我試圖將.net 4.6.1 package用於.net core app。我成功下載了nuget軟件包。但在嘗試將依賴關係註冊爲服務時,它會拋出錯誤。無法在.Net Core應用程序中安裝`mscorlib`

services.AddTransient<IJobSchedulerIntegrator, JobSchedulerIntegrator>(); //throwing error that mscorlib needs to be installed 

錯誤

The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 

enter image description here

作爲類JobSchedulerIntegrator爲繼承object。它需要mscorlib。但我不能將mscorlib安裝到.net core應用程序中。

有沒有反正我可以解決這個問題。

Project.json

{ 
    "dependencies": { 
    "API.Framework.Integrators.JobScheduler": "1.0.0", 
    "BundlerMinifier.Core": "2.2.281", 
    "Microsoft.AspNetCore.Authentication.Google": "1.0.0", 
    "Microsoft.AspNetCore.Diagnostics": "1.0.0", 
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0", 
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0", 
    "Microsoft.AspNetCore.Mvc": "1.0.0", 
    "Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0", 
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", 
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0", 
    "Microsoft.AspNetCore.StaticFiles": "1.0.0", 
    "Microsoft.EntityFrameworkCore.Design": "1.0.0-preview2-final", 
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0", 
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final", 
    "Microsoft.Extensions.Caching.Abstractions": "1.0.0", 
    "Microsoft.Extensions.Caching.Memory": "1.0.0", 
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", 
    "Microsoft.Extensions.Configuration.Json": "1.0.0", 
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0", 
    "Microsoft.Extensions.DependencyInjection": "1.0.0", 
    "Microsoft.Extensions.Logging": "1.0.0", 
    "Microsoft.Extensions.Logging.Console": "1.0.0", 
    "Microsoft.Extensions.Logging.Debug": "1.0.0", 
    "Microsoft.NETCore.App": { 
     "version": "1.0.0", 
     "type": "platform" 
    }, 
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0", 
    "Newtonsoft.Json": "9.0.1", 
    "Serilog": "2.0.0", 
    "Serilog.Extensions.Logging": "1.0.0", 
    "Serilog.Sinks.Literate": "2.0.0", 
    "System.Runtime.Extensions": "4.1.0", 
    "System.Security.Cryptography.Algorithms": "4.2.0" 
    }, 
    "tools": { 
    "BundlerMinifier.Core": "2.0.238", 
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final", 
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final", 
    "Microsoft.EntityFrameworkCore.Tools": { 
     "version": "1.0.0-preview2-final", 
     "imports": [ 
     "portable-net45+win8+dnxcore50", 
     "portable-net45+win8" 
     ] 
    } 
    }, 

    "frameworks": { 
    "netcoreapp1.0": { 
     "imports": [ 
     "net461", 
     "dotnet5.6", 
     "dnxcore50", 
     "portable-net452+win81" 
     ] 
    } 
    }, 

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

    "runtimeOptions": { 
    "gcServer": true 
    }, 

    "publishOptions": { 
    "include": [ 
     "wwwroot", 
     "Views", 
     "appsettings.json", 
     "web.config" 
    ] 
    }, 

    "scripts": { 
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ], 
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] 
    } 
} 
+0

你可以添加你的project.json文件嗎? – Kalten

+0

@Kalten,增加了project.json內容。 – Venky

+0

重複http://stackoverflow.com/questions/38646466/referencing-mscorlib-4-0-0-0-from-net-core-1-0-class-library/38688430#38688430 – Thomas

回答

1

進口部分比推薦更多的黑客攻擊。這允許你使用一個nuget包,而不是明確地指定一個當前的框架。

如果軟件包的內容不包含兼容的dll,那就無法工作。 您應該用任何其他兼容的替代目標框架netcoreapp1.0(如NET46)並刪除imports

+0

感謝Kalten,但是如果我將目標框架更改爲NET46,那麼該應用程序並不是一個.net核心應用程序。我想我正在尋找更多的建議。 – Venky