I have a job which takes a user defined object as one of the parameters. Hangfire is able to queue and trigger the job when everything is working normally, however if the job throws an exception and Hangfire requeues it, it will always fail to start the job with this error:
(Where obviously Full.Class, Assembly Name etc is the replaced with the real name of my class)
Error converting value "Full.Class, Assembly Name etc" to type 'System.Type'. Path '[1]', line 1, position 214.
Newtonsoft.Json.JsonSerializationException: Error converting value "Full.Class, Assembly Name etc" to type 'System.Type'. Path '[1]', line 1, position 214. ---> System.ArgumentException: Could not cast or convert from System.String to System.Type.
at Newtonsoft.Json.Utilities.ConvertUtils.EnsureTypeAssignable(Object value, Type initialType, Type targetType)
at Newtonsoft.Json.Utilities.ConvertUtils.ConvertOrCast(Object initialValue, CultureInfo culture, Type targetType)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
--- End of inner exception stack trace ---
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at Hangfire.Common.JobHelper.FromJson[T](String value)
at Hangfire.Storage.InvocationData.Deserialize()
Note that my class is in a different DLL, which may be relevant.