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:
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
Hangfire.BackgroundJob.Enqueue(o => o.Execute(
new JobCancellationToken(false) as IJobCancellationToken,
BTW, IJobCancellationToken and JobCancellationToken behaves the same way.
If I take the setting out and serialize the token manually, it works…