我有一个现有的 ASP.NET 项目,但它不在 MVC 中。当我尝试安装 Hangire 时,出现此错误。
PM> Install-Package Hangfire
Attempting to gather dependency information for package 'Hangfire.1.5.8' with respect to project 'FYMAS', targeting '.NETFramework,Version=v4.0'
Attempting to resolve dependencies for package 'Hangfire.1.5.8' with DependencyBehavior 'Lowest'
Resolving actions to install package 'Hangfire.1.5.8'
Resolved actions to install package 'Hangfire.1.5.8'
Adding package 'Newtonsoft.Json.5.0.1' to folder 'C:\Users\User\Desktop\hang\packages'
Added package 'Newtonsoft.Json.5.0.1' to folder 'C:\Users\User\Desktop\hang\packages'
Added package 'Newtonsoft.Json.5.0.1' to 'packages.config'
Successfully installed 'Newtonsoft.Json 5.0.1' to FYMAS
Install failed. Rolling back...
Package 'Hangfire.Core.1.5.8 : Newtonsoft.Json [5.0.0, ), Owin [1.0.0, )' does not exist in project 'FYMAS'
Removed package 'Newtonsoft.Json.5.0.1' from 'packages.config'
Package 'Hangfire.Core.1.5.8 : Newtonsoft.Json [5.0.0, ), Owin [1.0.0, )' does not exist in folder 'C:\Users\User\Desktop\hang\packages'
Removing package 'Newtonsoft.Json.5.0.1' from folder 'C:\Users\User\Desktop\hang\packages'
Removed package 'Newtonsoft.Json.5.0.1' from folder 'C:\Users\User\Desktop\hang\packages'
Install-Package : Could not install package 'Hangfire.Core 1.5.8'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package
does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
At line:1 char:1
+ Install-Package Hangfire
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
我尝试使用Install-Package Owin
命令将owin安装到我的项目中,安装成功,但是当我再次尝试安装hanfire时,出现了相同的错误。我尝试使用 Install-Package HangFire -Version 1.4.6
安装旧版本的 Hangfire,但遇到了相同的错误。
最佳答案
看来你的问题是你的.NET框架,你使用的是4.0,那么你应该为你的框架安装hangfire,试试这个
Install-Package Hangfire_net40
当您使用Install-Package Hangfire
时,这将安装最新的稳定版本(在您的情况下为Hangfire.1.5.8,这需要更新的.net框架〜4.5)。欲了解更多详情, Hangfire (.Net 4.0) 1.1.1
关于asp.net - 无法将 Hangfire 安装到我现有的项目中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38116356/