HangfireIO/Hangfire · error · JobPerformanceException
An exception occurred during arguments deserialization.
Error message
An exception occurred during arguments deserialization.
What it means
Thrown as JobPerformanceException (message 'An exception occurred during arguments deserialization.') wrapping any catchable exception raised while the obsolete GetArguments method reconstructs the argument list for method invocation. The method iterates the job's parameters and matches them against stored Args; any failure (index out of range, type mismatch, nullability) is wrapped and rethrown at lines 126-131.
Source
Thrown at src/Hangfire.Core/Obsolete/Job.Obsolete.cs:128
object value;
if (typeof(IJobCancellationToken).GetTypeInfo().IsAssignableFrom(parameter.ParameterType.GetTypeInfo()))
{
value = cancellationToken;
}
else
{
value = argument;
}
result.Add(value);
}
return result.ToArray();
}
catch (Exception ex) when (ex.IsCatchableExceptionType())
{
throw new JobPerformanceException(
"An exception occurred during arguments deserialization.",
ex);
}
}
[Obsolete("Will be removed in 2.0.0")]
private object InvokeMethod(object instance, object[] deserializedArguments, IJobCancellationToken cancellationToken)
{
try
{
return Method.Invoke(instance, deserializedArguments);
}
catch (TargetInvocationException ex)
{
CoreBackgroundJobPerformer.HandleJobPerformanceException(ex.InnerException, cancellationToken, null);
throw;
}
}View on GitHub (pinned to c236dd0f93)
Solutions
- Inspect the InnerException of the JobPerformanceException to identify the exact argument/parameter mismatch.
- Ensure deployed job method signatures match the jobs already in storage — avoid changing parameter counts/types on methods referenced by pending jobs, or clear the affected jobs.
- If you must change a signature, version the method (new name) or drain the queue before deploying.
Example fix
// before — method signature changed, stored args no longer match
public void Send(string to) { ... }
// pending job stored with 2 args fails deserialization
// after — keep the old overload and add a new method
public void Send(string to) { ... }
public void SendWithTemplate(string to, string template) { ... } Defensive patterns
Strategy: try-catch
Validate before calling
// Validate stored argument count matches the method before performing:
if (job.Method.GetParameters().Length != job.Args.Count)
throw new InvalidOperationException("Stored args do not match method signature."); Try / catch
try { job.Perform(activator, token); }
catch (JobPerformanceException ex) when (ex.Message.Contains("arguments deserialization"))
{
logger.LogError(ex.InnerException, "Arg deserialization failed for {Method}", job.Method);
} Prevention
- Do not change job method signatures while compatible jobs are still queued — version the method or drain the queue.
- Inspect InnerException to pinpoint the mismatched parameter.
- Avoid manually editing stored job arguments.
When it happens
Trigger: Job.Perform (obsolete) calls GetArguments(cancellationToken) which iterates Method.GetParameters() and indexes into Args. An exception occurs if the stored argument count does not match the method's parameter count, a stored argument cannot be assigned to its parameter type, or the method signature changed since the job was enqueued (e.g. parameter added/removed, type changed).
Common situations: A stored job references an older method signature after a deployment that changed parameter count or types; serialization produced a value incompatible with the parameter (e.g. a JSON deserialization returning null for a non-nullable struct); a corrupt or manually-edited job state with truncated arguments.
Related errors
- An exception occurred during job activation.
- Job has been performed, but an exception occurred during dis
- activator
- JobActivator returned NULL instance of the '{Type}' type.
- Background job creation failed. See inner exception for deta
AI-assisted analysis of HangfireIO/Hangfire@c236dd0f93 (2026-08-13).
Data as JSON: /api/errors/e508ea2e83c1cdc1.
Report an issue: GitHub.