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

时间:2016-06-30 07:18:50

标签: asp.net hangfire

我有一个现有的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,但遇到了同样的错误。

1 个答案:

答案 0 :(得分:2)

看来您的问题是您的.NET框架,您使用的是4.0,那么您应该为您的框架安装hangfire,试试这个

Install-Package Hangfire_net40

当您使用Install-Package Hangfire时,这将安装最新的稳定版本(在您的情况下,Hangfire.1.5.8,这需要更新的.net framework~4.5)。有关详细信息,请 Hangfire (.Net 4.0) 1.1.1