HangFire in moduleapplication. Could not load file or assembly


First of all my first impression with Hangfire si great. Good job. :slight_smile: In the past i had my ovn implementation of background jobs but it had limited features so i decided to try one and I selected Hangfire.

I have module aplications. This means that is logic seperated in different assemblyes.
I made ContainerJobActivator whic recognise via IoC all my currently loaded assemblyes.

Everything work until i try added one task whic doesn’t have definition in my main assembly.

This registration make problem:

RecurringJob.AddOrUpdate<CheckMailTask>(GetType().FullName, (t) => t.Process(), "*/5 * * * *");

I get error :

Could not load file or assembly 'xxx.yyyy', Version=, 
Culture=neutral, PublicKeyToken=null' or one of its dependencies. The 
system cannot find the file specified.

I found work around. If I instant Class as Interface whic is declared in main assambly it work correctly.

RecurringJob.AddOrUpdate<ITaskMailChecker>(GetType().FullName, (t) => t.Process(), "*/5 * * * *");

This workaroud works only until i have one implementation of ITaskMailChecker.

If understand correctly Hangfire use Newtonsoft.Json to seralize. I think that problem because Newtonsoft.Json
doesn’t find my dynamicly loaded assemblyes. It shoud be fine if you add one optional (virtual) method in JobActivator.

And this method return list of loaded assemplyes whic are used for Json seralization. In my case i just have to override this metod and return my list of loaded assemblyes.

Kind regards,

Have you seen the following post?