Job enqueue doesn't support generic methods
See original GitHub issueHangfire should support it on Sql implementation, but generic method parameters are not serialized into the MongoDB document.
Trying to enqueue a call to a generic method I receive Can not find the target method.
Failed
Can not change the state to 'Processing': target method was not found.
System.ArgumentNullException
Value cannot be null.
System.ArgumentNullException: Value cannot be null.
at System.Reflection.RuntimeMethodInfo.MakeGenericMethod(Type[] methodInstantiation)
at Hangfire.Common.TypeExtensions.GetNonOpenMatchingMethod(Type type, String name, Type[] parameterTypes)
at Hangfire.Storage.InvocationData.Deserialize()
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Job enqueue doesn't support generic methods · Issue #165
Trying to enqueue a call to a generic method I receive Can not find the target method. Failed Can not change the state...
Read more >Using Hangfire: generic Enqueue<T> method throws ...
SqlServer packages installed. In my main method I enqueue a background job like this: BackgroundJob.Enqueue<Test>((t) => Console.WriteLine ...
Read more >System.InvalidOperationException when Enqueue Generic ...
I'm getting following exception. The type Harmony.Admin.Service.IEmailService does not contain a method with signature SendAsync(String). System ...
Read more >How to write generic classes and methods in Java
This Java Generics tutorial helps you design highly general and reusable libraries with generic classes and methods.
Read more >Basics of Generics in Scala
We'll go through the steps of writing generic classes and methods and explore the generic types available in the standard Scala library.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I didn’t write tests, but I wrote very simple cases where this and another (I think very similar and related) issues appear. On Asp.net Core sample project you can add these lines on
HomeController
:If you invoke the
FailingOnServer
action you will receive the previously mentioned exception by server execution, but if you call theFailingOnClient
action you will get this exception directly on client enqueuing:Thank you for your help! You have found my issue, because into my project I don’t have a parameter for each generic type that I pass. I’m using these generic types with an other internal logic, but I’ve actually solved invoking an other not-generic proxy method that takes these types as arguments, and use reflection for invoke the generic one.
If hangfire could serialize also generic types it would be great!