With one of my projects, I am still stuck using net451 because of other dependencies. I am unable to use Hangfire because it does not seem to be available.
// project.json
"dependencies": {
...
"Hangfire": "1.6.2",
...
},
"frameworks": {
"net451": {}
}
// Startup.cs
using Hangfire;
...
public void ConfigureServices(IServiceCollection services)
{
// throws: 'IServiceCollection' does not contain a definition for 'AddHangfire' and no extension method 'AddHangfire' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?)
services.AddHangfire(config =>
{
config.UseSqlServerStorage(Configuration["Database"]);
});
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
// throws: 'IApplicationBuilder' does not contain a definition for 'UseHangfireServer' and the best extension method overload 'AppBuilderExtensions.UseHangfireServer(IAppBuilder)' requires a receiver of type 'IAppBuilder'
app.UseHangfireServer();
}
Have you tried to add Hangfire.AspNetCore package? I think it is not a part of Hangfire meta-package.
Ahh yes that fixes the issue. I also needed to add Hangfire.SqlServer for my implementation case:
"Hangfire.AspNetCore": "1.6.2",
"Hangfire.SqlServer": "1.6.2"
Thanks
Most helpful comment
Have you tried to add
Hangfire.AspNetCorepackage? I think it is not a part ofHangfiremeta-package.