Quantcast
Channel: User MikelThief - Stack Overflow
Viewing all articles
Browse latest Browse all 26

Answer by MikelThief for Hangfire Recurring jobs not working - throw exception: "Unable to find a constructor"

$
0
0

A good solution is to have connectionstring set up part as IOption or something similar like binding configuration to some object and then contructor-injecting this object to a class which contains method acting as recurring job.

Example:

public StatusJobs(DbOptions dbOptions)
{
    _dbOptions= dbOptions
}

[DisableConcurrentExecution(timeoutInSeconds: 20)]
[AutomaticRetry(Attempts = 0, OnAttemptsExceeded = AttemptsExceededAction.Delete)]
public void DoSmth()
{
    //dbOptions avalaible here
}

Also, it would be better to inject some connectionfactory instead of connectiostring.


Viewing all articles
Browse latest Browse all 26

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>