The simplest method to use background jobs in distributed scenarios, where the processing is being placed into another process, is to use interfaces for background jobs and place them into a common assembly:
public interface IBackgroundJobs
{
void CheckForSpam(int commentId);
}
So, the project that enqueues jobs should have reference only to assembly with interface to enqueue a job:
BackgroundJob.Enqueue<IBackgroundJobs>(x => x.CheckForSpam(commentId));
The project that processes jobs (Windows Service project, for example), also have a reference to the common assembly with interfaces declared. But it has implementation of these interfaces also:
public void BackgroundJobsImplementation : IBackgroundJobs
{
public void CheckForSpam(int commentId)
{
/* ... */
}
}
You’ll need to use an IoC container to make a relation between an interface and an implementation that will be known for Hangfire.