I have a DLL containing some methods (show, hide and validate). Here is an example of one of the methods hide(Panel paneldynamic, String id, List<EventActions> eventList). All methods contains the same parameters.
Now I have referenced the my DLL on my main form, how can I dynamically invoke one of the methods at runtime?
You’ll need to use reflection. First, load the assembly (note that this assumes you’ve imported
System.Reflection):Get the type containing the method by fully-qualified name:
Now, get the method:
Then, all you have to do is invoke it:
The first argument to
Invokeis the instance. If your class isstatic, usenull, otherwise, you’ll need to supply an instance of the type created usingAssembly.CreateInstance.