Objective: Have a running hosted service processing queues (from a cloud service) and dynamically route them to the controller. Kind of like in php with the Larval framework calling jobs.
Current Implementation:
Type type = Type.GetType(nameSpace + ".Controllers." + sqsMessage.controller);
Object obj = Activator.CreateInstance(type, null);
MethodInfo methodInfo = type.GetMethod(sqsMessage.method);
result = methodInfo.Invoke(obj, sqsMessage.body);
Why current implementation does not work: The controllers have constructors that arguments vary, and the queue sender should not have to be responsible for passing those arguments:
example:
Controller 1 - Constructor 1 task the ILogger argument
Controller 2 - Constructor takes zero arguments
Question: How do I dynamically call a controller and specific action from a running background service?
using asp.net core 2.1