Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

call method at runtime

I am wondering if it is possible to load a .net DLL at runtime, view the methods available and execute one at runtime.

If this is possible could you point me in the right direction

like image 406
fishhead Avatar asked Jan 31 '10 18:01

fishhead


People also ask

How do you call a method in a string?

There are two methods to call a function from string stored in a variable. The first one is by using the window object method and the second one is by using eval() method. The eval() method is older and it is deprecated.


1 Answers

Generally, you use System.Reflection classes to do this task.

Specifically, you'd load the DLL via Assembly.Load (or Assembly.LoadFrom) and then call Assembly.GetTypes and then for each type call Type.GetMethods. When you have a MethodInfo, you can call MethodInfo.Invoke on it.

like image 141
codekaizen Avatar answered Oct 20 '22 09:10

codekaizen