I'm getting this runtime exception with Hangfire after upgrading to .NET6
System.TypeLoadException: Could not load type 'System.Collections.Generic.ISet`1' from assembly 'mscorlib, Version=4.0.0.0
at Hangfire.Common.TypeHelper.TypeResolver(Assembly assembly, String typeName, Boolean ignoreCase)
at Hangfire.Common.TypeHelper.DefaultTypeResolver(String typeName)
at System.Linq.Enumerable.SelectArrayIterator`2.ToArray()
at Hangfire.Storage.InvocationData.DeserializeJob()
ISet isn't in mscorlib.dll from what I can tell. It's supposed to be in System.Runtime.dll according to the docs.
Any ideas why Hangfire is doing this? I'm using Hangfire.AspNetCore 1.7.27.
As said in the comments, you should look in your Hangfire database for a serialized parameter featuring a ISet
.
It is the deserialization of this parameter which causes the issue, as indicated by :
at Hangfire.Storage.InvocationData.DeserializeJob()
As to the root cause of the problem, I was first thinking that the job had been enqueued with an older version of the framework, while the dequeue attempt was with a newer version of the framework. But this might also be a serialization settings issue, as stated by this older answer