How to call a method when using reflection?

I have an assembly that loads using Assembly.LoadFrom. This assembly contains several static methods, how can I call them after the assembly is loaded correctly.

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ReflectionSandbox { public class Class1 { public static void TestAPI() { Console.WriteLine("TestAPI"); } } } 
+4
source share
1 answer
 someAssembly.GetType(someName).GetMethod(someName).Invoke(null, someParameters) 

null - argument to instance ( this ); It must be empty for static methods.

+5
source

Source: https://habr.com/ru/post/1395026/


All Articles