我試圖將.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'.
作爲類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%" ]
}
}
你可以添加你的project.json文件嗎? – Kalten
@Kalten,增加了project.json內容。 – Venky
重複http://stackoverflow.com/questions/38646466/referencing-mscorlib-4-0-0-0-from-net-core-1-0-class-library/38688430#38688430 – Thomas