Hi
I know that Hangfire.JobActivator allow dynamic object creation. It accepts Type as parameter.
However, I would like to implement class factory that use classKey string as parameter and retrieve its fully qualified assembly and type name from xml file.
All of the job object must implement IMyJob interface, and BackgroundJob.Enqueue( x=> x.Execute(parameter); )
Implemented actual job classes are not added into project reference. Instead via “dynamic dll”.
Question
How to implement this ?
If Hangfire doesn’t support this natively, I was thinking to have my own classFactory, create the object and get the GetType() to pass to BackgroundJob.Enqueue(). The job dll will be located in same folder with Hangfire. Does this design compatible?
If answer to question2 is yes, do you think it is working fine for RecurringJob as well?
When I check table Hangfire.Hash, found that Hash.Value = “Type”:“ProjectA.IJob, xxxxxxx” instead of ProjectB.JobA.
I double checked hangfire source code, Job.FromExpression() actually referring to callExpression.Method.DeclaringType, which always return the type where the method is declared.
It cause JobActivator unable to instantiate ProjectA.IJob. I tried to use ReflectedType, it return same type.
How to solve this problem?