mercredi 27 septembre 2017

How to load a function from DLL and detect the function's parameter type?

I'm writing a C# application from which I want to load some C# DLLs at run time. The DLLs will be expected to export a class that subscribes to an interface like below ...

interface IHandler {
  HandlerResponse Start(HandlerArgs args);
}

The IHandler interface is just to require the DLLs to export a common entry point function that I can call.

My problem and question is that I want that HandlerArgs to change based on the DLL. The HandlerArgs will be a data transport class into the DLLs Start function. It won't be called HandlerArgs, it'll be a different type for each DLL based on the params that DLL needs. So, the interface that I currently have, from above, doesn't work.

I need the caller function to be able to load the DLL, create an instance of the necessary parameter type and pass that instance to the Start function.

Is it possible to do this?





Aucun commentaire:

Enregistrer un commentaire