LoadDynamicController
Part of the QSAppContext object. Dynamically loads a controller assembly by its name from the server and returns the controller instance as a dynamic object. This is useful for late‑binding or plugin‑style scenarios where the exact type is not known at compile time.
If the controller name is null or empty, an ArgumentException or ControllerNotFoundException is thrown. If the assembly cannot be loaded, a ControllerNotFoundException is thrown with the server error message.
Signature
public async Task<dynamic> LoadDynamicController(string controllerName)Parameters
| Name | Type | Description |
|---|---|---|
controllerName | string | The name of the controller assembly to load. It should match the registered name on the server. |
Exceptions
ArgumentException– ifcontrollerNameisnullor empty.ControllerNotFoundException– if the controller name is empty or the assembly cannot be loaded.
Returns
A Task<dynamic> representing the asynchronous operation. The result is the loaded controller instance, typed as dynamic so you can invoke its members without compile‑time type checks.
Example Usage
// Load a dynamic controller by name
string controllerName = "CustomerReportController";
dynamic controller = await QSAppContext.LoadDynamicController(controllerName);
// Invoke a method on the dynamically loaded controller
var result = controller.GenerateReport("CUST-001");
Console.WriteLine(result);