0

I use hangfire in a webforms project. Hangfire itself was working. Then I installed Hangfire.Console extension to add log messages, but now I get an error

Error CS0234
The type or namespace name 'Console' does not exist in the namespace 'Hangfire' (are you missing an assembly reference?) HangTest2

My code:

Packages:

enter image description here

Global:

enter image description here

Startup:

enter image description here

As you have noted there is no usecosole - what am I doing wrong?

I'm using .NET Framework 4.7 and an ASP.NET webforms project

Edit

auto complete working with hangfire.console enter image description here

Edit : the link is talking about Hangfire with log packages My Question about the package Hangfire.Console

Maher Khalil
  • 519
  • 13
  • 26
  • In your startup, use `GlobalConfiguration.Configuration.UseConsole();` right after your `UseSqlServerStorage()` method. – Jawad Dec 22 '21 at 03:09

1 Answers1

0

You need to use like this.

.UseSqlServerStorage("connectionSting")
    .UseConsole();

Hangfire.Console provides extension methods on PerformContext object, hence you'll need to add it as a job argument. NOTE: Like IJobCancellationToken, PerformContext is a special argument type which Hangfire will substitute automatically. You should pass null when enqueuing a job. Now you can write to console:

public void TaskMethod(PerformContext context)
{
    context.WriteLine("Hello, world!");
}

Reference: https://github.com/pieceofsummer/Hangfire.Console

vivek nuna
  • 16,885
  • 12
  • 74
  • 152