am creating a base hangfire class which provides inheritance. to avoid including hangfire in all modules I pass the JobCancellation token to a method as an object to the BackgroundJob.Enqueue lamba. by default it cannot be deserialized. I saw a setting:
Hangfire.Common.JobHelper.SetSerializerSettings(new Newtonsoft.Json.JsonSerializerSettings
{
TypeNameHandling = Newtonsoft.Json.TypeNameHandling.All
});
when this is included, the token is properly deserialized/serialized but when the task is run, it fails every time with an SEHException
The method:
Hangfire.BackgroundJob.Enqueue(o => o.Execute(
new JobCancellationToken(false) as IJobCancellationToken,
parms));
BTW, IJobCancellationToken and JobCancellationToken behaves the same way.
If I take the setting out and serialize the token manually, it works…
please advise