I am trying to find a way in which I can execute code from a .NET DLL after my application has already been launched. I have included some pseudo-code below that might try and explain what I’m trying to do. I know it’s probably a lot more complicated than I make it seem.
ClassLibrary myLibrary = new ClassLibrary("C:\\Users\\Admin\\Desktop\\myTestLibrary.dll");
myLibrary.executeMethod("showMessageMethod", arg1, arg2, arg3...);
That’s what I want to do although I understand it’s likely far more complicated than that!
I would also like to make it clear that I do understand that you’re meant to reference the library in your project etc… but my project requires that I don’t do it this way.
Thanks in advance!
You’ll need to load the assembly from disk, as follows:
After that you will need to get the proper type using reflection and invoke the proper method. It will be most convenient when that class you want to call implements an interface that is defined in an assembly that is referenced at startup: