Reputation: 1795
I'm trying to setup Hangfire in VS 2013, I've installed it thru Package Manager. However, when I added the app.UseHangfire (...) code as stated in http://docs.hangfire.io/en/latest/quick-start.html. I'm getting the following error:
'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?)
Upvotes: 2
Views: 4036
Reputation: 589
Starting from version 1.4 Config is obsolete, use GlobalConfiguration instead:
public partial class Startup {
public void Configuration(IAppBuilder app)
{
GlobalConfiguration.Configuration
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
.UseSqlServerStorage(System.Configuration.ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString, new SqlServerStorageOptions
{
CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
QueuePollInterval = TimeSpan.Zero,
UseRecommendedIsolationLevel = true,
DisableGlobalLocks = true
});
app.UseHangfireDashboard();
app.UseHangfireServer();
...
}
Upvotes: 0
Reputation: 35597
Did you add the namespace?
using Hangfire;
Your Startup
should look something like this:
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
//});
});
}
}
Upvotes: 7
Reputation: 461
Updating the HangFire.Core package to latest solved it for me. Seems OWIN is installing an older package as dependency
Upvotes: 0