1

我正在尝试在 VS 2013 中设置 Hangfire,我已经通过包管理器安装了它。但是,当我按照http://docs.hangfire.io/en/latest/quick-start.html中的说明添加 app.UseHangfire (...) 代码时。我收到以下错误:

'Owin.IAppBuilder' does not contain a definition for 'UseHangfire' and no extension method 'UseHangfire' accepting a first argument of type 'Owin.IAppBuilder' could be found (are you missing a using directive or an assembly reference?)
4

2 回答 2

7

你添加了命名空间吗?

using Hangfire;

Startup应该看起来像这样:

using Hangfire;
using Hangfire.SqlServer;
using Hangfire.Dashboard;

public class Startup
{
    public void Configuration(IAppBuilder app)
        {
            app.UseHangfire(config =>
            {
                config.UseSqlServerStorage("Data Source=<connectionstring>; Initial Catalog=HangFire; Trusted_Connection=true;");
                config.UseServer();

                //config.UseAuthorizationFilters(new AuthorizationFilter
                //{
                //    // Users = "admin, superuser", // allow only specified users
                //    Roles = "admins" // allow only specified roles
                //});
            });
    }
}
于 2015-01-12T17:33:43.520 回答
0

将 HangFire.Core 包更新到最新版本为我解决了这个问题。似乎 OWIN 正在安装一个较旧的软件包作为依赖项

于 2016-12-14T16:10:07.250 回答