face-it / Hangfire.Tags

Add tags to Hangfire backgroundjobs
MIT License
91 stars 26 forks source link

FaceIT.Hangfire.Tags.SqlServer breaks with Hangfire.SqlServer 1.8.15 #97

Open AlexMedia opened 3 weeks ago

AlexMedia commented 3 weeks ago

After upgrading Hangfire.SqlServer to version 1.8.15, this package no longer works. The following error gets logged when trying to execute a task:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Hangfire.Tags.SqlServer.SqlTagsTransaction..ctor(SqlServerStorageOptions options, IWriteOnlyTransaction transaction)
   at Hangfire.Tags.SqlServer.SqlTagsServiceStorage.GetTransaction(IWriteOnlyTransaction transaction)
   at Hangfire.Tags.Storage.TagExpirationTransaction.Persist(String jobid)
   at Hangfire.Tags.States.TagsCleanupStateFilter.OnStateApplied(ApplyStateContext context, IWriteOnlyTransaction transaction)
   at Hangfire.States.StateMachine.InvokeOnStateApplied(KeyValuePair`2 x) in C:\projects\hangfire-525\src\Hangfire.Core\States\StateMachine.cs:line 116

The root cause lies in this bit of reflection: https://github.com/face-it/Hangfire.Tags/blob/5038a69e3a8496168320590fd22fc8789c5de791/src/FaceIT.Hangfire.Tags.SqlServer/SqlTagsTransaction.cs#L71-L77 as it tries to get the SqlCommandBatchParameter type, which no longer exists in Hangfire.SqlServer 1.8.15.

smadep commented 2 weeks ago

facing same problem ...