Change InvocationData manually

Hello,

we are running a Hangfire Server and an application named SchoolApp where I have to add a Hangfire Background Job.

The Hangfire server is running and with my local testing application it is working fine, with the SchoolApp it is not working.

The problem is, that the InvocationData is wrong (I think it is the assembly). Here is what is executing on the Hangifre server when i use my local test app (the job entry in the database):

{"Type":"HangfireServer.Service, HangfireServer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","Method":"Execute","ParameterTypes":"..."]","Arguments":null}

When I want to try it in the SchoolApp, the Job “Succeeded” but nothing happens, and it is storaged in the database as follows:

{"Type":"HangfireServer.Service, SchoolApp, Version=2.1.1.1, Culture=neutral, PublicKeyToken=null","Method":"Execute","ParameterTypes":"..."]","Arguments":null}

The call is looking like this:

var client = new BackgroundJobClient();
var job = client.Enqueue(() => HangfireServer.Service.Execute(token, jsonData));

So I think the problem is, that it is searching for a “SchoolApp” Lib/Method on the Hangfire server, but there is none and I am not allowed to change anything in the SchoolApp to HangfireServer. So my question is: Can I change a parameter or something, that I can achieve it?

The situation is not clear.
Is the SchoolApp running on the same server/process as Hangfire or is it on two different servers or processes?
I understand that you do have access to the source code of the school app that does the enqueueing right?
If you have two different processes that both communicate through the same DB, one for the pure SchoolApp and another for Hangfire, you need the to be in the same solution so that the Hangfire binary will have access to the SchoolApp code.
You’ll need to build two different assemblies/artifacts, one for SchoolApp (SA) and another for SchoolAppHangfire (SAH).
Both assemblies will need to run in parallel and SAH will find the SA code by reflection so it can execute it.

If you have more questions please feel free to ask

Hello Vladik, no it is a different, it is the “client” if you want. Yes I have access to the source code of the SchoolApp.

The Hangfire Server is running on an IIS. I am not sure if I am allowed to build another solution (it’s a strict architecture thing).

So there is no easy solution, to change the DB entry "Type":"HangfireServer.Service, SchoolApp, ... to "Type":"HangfireServer.Service, HangfireServer, ..., maybe it is an easier way to kinda manipulate it? Is this possible? Because I just need to change the Asemblyy name. Then it would be the correct DB entry and the Hangfire server would recognize it and would use the correct method in the background.

Do you use the Hangfire dashboard?
I don’t understand how the job succeeds because reflection can’t find the code, or can it?
If you change the DB entry manually using SQL and trigger the job, does it work and do what you want?