![](https://pic002.cnblogs.com/images/2010/200498/2010112316575973.png)
![](https://pic002.cnblogs.com/images/2010/200498/2010112316524840.png)
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Reflection;
6
7 namespace StuCon
8 {
9 class Program
10 {
11 static void Main(string[] args)
12 {
13 object obj = Assembly.Load("UserDao").CreateInstance("UserDao.UserDao");//“UserDao”为需要加载的dll文件,"UserDao.UserDao"为该dll文件所在的程序的命名空间下的类名
14 string methodName = Console.ReadLine();//输入方法名
15 PropertyInfo pro = obj.GetType().GetProperty("Name");//获取该dll程序集下的属性名
16 pro.SetValue(obj, "Hello", null);//给属性赋值
17 MethodInfo m = obj.GetType().GetMethod(methodName);//获取方法名
18 m.Invoke(obj, null);//使用指定的参数调用当前实例所表示的方法或构造函数
19 Console.ReadLine();
20 }
21 }
22 }
23
![](https://pic002.cnblogs.com/images/2010/200498/2010112316512914.png)