JsonSerializationException when changing job state to 'Processing'

I’m getting an issue with in production using Hangfire 1.4.3.

The thing is that this is an intermittent issue, some jobs correctly deserialize, most don’t.

State.Reason

Can not change the state of a job to ‘Processing’: target method was not found.

State.Data

{
    "FailedAt":"2015-07-07T23:57:49.3017899Z",
    "ExceptionType":"Newtonsoft.Json.JsonSerializationException",
    "ExceptionMessage":"Error converting value \"Core.Activities.ActivityExecutionType, Core, Version=2015.2.0.19230, Culture=neutral, PublicKeyToken=8e650edd8c6b2107\" to type 'System.Type'. Path '[1]', line 1, position 257.",
    "ExceptionDetails":"Newtonsoft.Json.JsonSerializationException: Error converting value \"Core.Activities.ActivityExecutionType, Core, Version=2015.2.0.19230, Culture=neutral, PublicKeyToken=8e650edd8c6b2107\" to type 'System.Type'. Path '[1]', line 1, position 257. ---> System.ArgumentException: Could not cast or convert from System.String to System.Type.\r\n   at Newtonsoft.Json.Utilities.ConvertUtils.EnsureTypeAssignable(Object value, Type initialType, Type targetType)\r\n   at Newtonsoft.Json.Utilities.ConvertUtils.ConvertOrCast(Object initialValue, CultureInfo culture, Type targetType)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)\r\n   --- End of inner exception stack trace ---\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\r\n   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)\r\n   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)\r\n   at Hangfire.Storage.InvocationData.Deserialize()"
}

Any thoughts?

Are your processors external to the app queuing your work items?

Could it be, if you have external processors, that one of them has an old reference to an assembly, so it cant new up the object you need from the JSON string?

When work items are queued, details about the assembly needed to deserialize your work item are stored in the queue. Details about the version number of assemblies are recorded.

Could it be, one of your processors has an old version of an assembly?

1 Like

I don’t think this is the issue.

I have 3 difference instances of the web application connected to the same database. Each instance is the exact same deployed version (2015.2.19230), so I don’t anticipate assembly version differences being the issue.