动态调用 类库

using System.Reflection; // 引入该命名空间

// 获取rocky.dll的文件路径
Assembly ass = Assembly.LoadFrom("./_lib/rocky.dll");
// 获取该dll中命名空间RockyNameSpace中Study类
Type type = ass.GetType("RockyNameSpace.Study");
// 实例化该类
object obj = Activator.CreateInstance(type);
// 获取该类中的方法StudyMath
MethodInfo mStudyMath = type.GetMethod("StudyMath");

// 使用方法
mStudyMath .Invoke(obj, new object[] { // 方法传递的参数 }));</span>

posted @ 2020-05-13 09:34  Mr_LiangJianan  阅读(144)  评论(0编辑  收藏  举报