Hangfire.Console Error with .NET Framework

541 views Asked by At

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

1

There are 1 answers

1
Vivek Nuna On

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