HangfireIO / HangfireIO/Hangfire

delegates and lambda expressions aren't supported in job method parameters: it's very hard to serialize them and all their scope in general

Open
#1,241 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
10.1k
Forks
1.8k
Avg merge
1h 19m
Merged PRs (30d)
1

Description

Hi
I call my job by hangfire in .net core like this:
`RecurringJob.AddOrUpdate(() => Job.FromExpression(x=>x.doSomething()), Cron.MinuteInterval(3));`

but I got this error
`System.NotSupportedException: 'Anonymous functions, delegates and lambda expressions aren't supported in job method parameters: it's very hard to serialize them and all their scope in general.'
`

then I change call method to this:
`var myJob = new Job(Dependency1, Dependency2);`
`RecurringJob.AddOrUpdate(() => myJob.doSomething(), Cron.MinuteInterval(3));`

and its work!!!

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the two RecurringJob.AddOrUpdate examples and tracing Job.FromExpression, the entry point named in the report. Inspect how the lambda, delegate, and captured scope are serialized, then define behavior for the failing example. Done means the reported form works without NotSupportedException, with coverage for this serialization case.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.