TL;DR: Solution is in my 2nd reply
I’m getting this error for a new job I added and I’m struggling to understand what I’m doing wrong.
I have the following project structure:
- Project A registers the dashboard and also acts as the default queue (which is not used)
- Project B processes jobs, contains implementation of the job interface
- Project C just enqueues jobs
- Library - contains interface for the job and a few other stuff; referenced by all projects
These are the code snippets that I assume are relevant:
// This is from project C
_backgroundJobClient.Enqueue<IMyJob>(x => x.ExecuteAsync(date0, date1, cycle));
// This is the interface in my library
public interface IMyJob
{
[Queue("worker_queue")]
[DisplayName("My Job")]
public Task ExecuteAsync(DateTime t0, DateTime tx, string cycle);
}
// This is the implementation from project B
public class MyJob : IMyJob
{
public Task ExecuteAsync(DateTime t0, DateTime tx, string cycle)
{
// Do stuff
}
}
// This is how I register the job in project B's startup
services.AddTransient<IMyJob, MyJob>();
My issue is as follows:
- Assuming there are no errors, the job is enqueued successfully and finishes successfully
- Job name (“My Job”) is displayed at all times in the dashboard
- If the job fails, I can successfully requeue the job manually using the requeue button and the job will start processing again without issues
- If I let the retry timer do its thing, processing doesn’t start and throws the following error
Failed
Can not change the state to 'Enqueued': target method was not found.
System.TypeLoadException
Could not load type 'Library.Jobs.IMyJob' from assembly 'Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
I know most answers suggest deploying the code version to all services, but as far as I can tell I did this:
- The job can be enqueued by project C, so this one can find the method
- Project B can process the job, so this one can find the method
- Project A not only displays the custom name, but I also logged
typeof(IMyJob)
at startup and it logs the full namespace
Does anyone have any suggestions? I’m really at a loss here.