Problem with Delayed Job - I am in big trouble

Hi
From dashboard, it shown exception “Can not find the target method.”. for schedule()

However, it I use enqueue, it is working perfectly.

var jobid = BackgroundJob.Enqueue(() => WriteX(“GGG”,
DerivedHangfireToken.Null));

Are you using separate application (console, windows service) for processing background jobs or have multiple applications using the same database?

Hi
I have tried this out in 2 environments, Console, and also Unit Testing.
Both doesn’t work.
And Yes, both shared the same database, however, neither the job scheduled in Console nor Unit Testing are working.

Please advice. thank you

Can you enumerate all of your applications and instances using Hangfire with shared database in the following way:

Front-end Web Application
Has a reference to assembly that contains WriteX method: Yes
Creates Background Jobs: Yes
Runs Hangfire Server: No

Back-end Web Application
Has a reference to assembly that contains WriteX method: No
Creates Background Jobs: No
Runs Hangfire Server: Yes

The problem is likely related to a missing assembly reference ensure all your applications have a reference to assembly that contains WriteX method.

Hi
After more testing, I found the exception only happen in below scenario,
In my unit testing,

  1. Start Server
  2. EnqueueJob
  3. Assert.IsTrue(ManualResetEvent.WaitOne(2000)) which will be set in my method.
  4. Stop Server

The problem here is, as I posted in another thread, SQL Server poll interval is 10 seconds. Before I know about this, I only wait for 2 secs, then will stop the server.

It seem like, if enqueued job not executed and server stopped, program would hit exception as posted above. I even hit some other weird exception either.

After I changed my code to wait more than 10 secs, everything back to normal.
So, my concern is, if that is any pending enqueued Job, and server stopped. Would it throw exception?