无法将 Hangfire 安装到我现有的项目中

Cannot install Hangfire to my existing project

我有一个现有的 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