此篇示範如何使用dll工具,簡單注入自己寫的dll
- 首先下載Dll注入工具,這裡我們用remotedll.
using System;
namespace TestReflc
{
class Program
{
static void Main(string[] args)
{
CreatePeopleByType();
Console.ReadLine();
}
static void CreatePeopleByType()
{
Type a = typeof(People);
// 動態創建物件,並且調用默認無參數的建構子(構造方法)
// 如果沒有定義無參數的建構子,那麼將出錯
var obj = Activator.CreateInstance(a);
// 輸出結果: PeoPle construction
}
}
public class People
{
public string Name;
public People()
{
Console.WriteLine("PeoPle construction");
}
}
}