I am trying to start Hangfire server in .Net Worker Service using example: Configure Hangfire dashboard in a worker service in .Net 5? answer by Ruslan Gilmutdinov https://stackoverflow.com/users/1734655/ruslan-gilmutdinov but following code
using Hangfire;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace WorkerServiceHangfire
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(builder =>
{
builder.Configure(app =>
{
app.UseRouting();
app.UseHangfireDashboard();
app.UseEndpoints(endpoints =>
{
endpoints.MapHangfireDashboard();
});
});
})
.ConfigureServices((hostContext, services) =>
{
services.AddHangfire(conf => conf.UseSqlServerStorage("connection string"));
services.AddHangfireServer();
services.AddHostedService<Worker>();
});
}
}
gives error at builder.Configure(app => line:
Error CS0411 The type arguments for method 'OptionsConfigurationServiceCollectionExtensions.Configure(IServiceCollection, IConfiguration)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
Any suggestions?