简体   繁体   中英

How to invoke a method when using reflection?

I have an assembly which is loaded using Assembly.LoadFrom. This assembly contains several static method, how can I invoke them once 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");
        }
    }
}
someAssembly.GetType(someName).GetMethod(someName).Invoke(null, someParameters)

The null is the instance ( this ) argument; it must be null for static methods.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM