Reputation: 539
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:
Global:
Startup:
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
Edit : the link is talking about Hangfire with log packages My Question about the package Hangfire.Console
Upvotes: 0
Views: 760
Reputation: 1
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
Upvotes: 0