Hangfire failes to load assembly

2019-02-24 21:36发布

问题:

Context

I have two application in place, one is my main enterprise application and in other I have hangfire (hangfire server, client and dashboard) hosted. My main application also use hangfire for some long task and executes them asynchronously. Both using the same DB for HF storage. And there is only one HF server.

Issue

I am getting the following errors intermittently -

"Can not change the state to 'Processing': target method was not found." OR

"Can not change the state to 'Enqueued': target method was not found."

with following details -

System.IO.FileNotFoundException

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

where MyApp.Hangfire is my hangfire application executing jobs. And I am sure that it is there, and even some successful jobs affirms it.

Please find the attached screenshot for more details.

Observation

The issue is not consistent, the job not always fails, sometimes it fails, re queued and get passed and sometimes when it is out of retries it even fails. As shown in screenshot

回答1:

I've stumbled upon the same issue a few days ago and decided it's worth adding it here.
Solution: added a reference to 'MyApp.Hangfire' in the dashboard web app.

Context was very similar or identical to yours:
-Hangfire server was running as a Windows service;
-Hangfire dashboard running on top of a ASP.NET MVC 5 app;
-jobs were actually running but dashboard kept displaying a FileNotFoundException;

Same problem was reported and solved in the same way by @reggieboyYEAH.
Details here: https://github.com/HangfireIO/Hangfire/issues/558



标签: c# hangfire