gpt4 book ai didi

c# - Owin 不包含 "UseHangfire"的定义,也没有扩展方法 "UseHangfire"

转载 作者:太空宇宙 更新时间:2023-11-03 18:28:39 26 4
gpt4 key购买 nike

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

'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?)

最佳答案

你添加命名空间了吗?

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
//});
});
}
}

关于c# - Owin 不包含 "UseHangfire"的定义,也没有扩展方法 "UseHangfire",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27907541/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com