I am getting “System.ArgumentException: Could not cast or convert from System.String to System.Type.”. I have copied the error below.
I get it while I am enqueuing a job
BackgroundJob.Enqueue(() => _emailSender.SendEmail(“xxxxx”, 25, “xxxx”, “xxxx”, “xxxx”))
Any help on this is appreciated. Thank you very much!
{“FailedAt”:“2018-01-10T19:52:24.0855131Z”,“ExceptionType”:“Newtonsoft.Json.JsonSerializationException”,“ExceptionMessage”:“Error converting value “System.String, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e” to type ‘System.Type’. Path ‘[0]’, line 1, position 107.”,“ExceptionDetails”:“Newtonsoft.Json.JsonSerializationException: Error converting value “System.String, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e” to type ‘System.Type’. Path ‘[0]’, line 1, position 107. —> 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(String value, Type type, JsonSerializerSettings settings)\r\n at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)\r\n at Hangfire.Common.JobHelper.FromJson[T](String value)\r\n at Hangfire.Storage.InvocationData.Deserialize()”}