[英]How to invoke a method when using reflection?
我有一個使用Assembly.LoadFrom加載的程序集。 這個程序集包含幾個靜態方法,如何正確加載程序集后如何調用它們。
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)
null
是實例( this
)參數; 對於靜態方法,它必須為null。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.