反射程序员的快乐
Assembly assemly = Assembly.Load("DB.MySql");//加载dll路径的名称的dll/exe 不需要后缀
Assembly assemly1 = Assembly.LoadFile(@"D:\online10\20171101Advanced10Course2Reflection\MyReflection\MyReflection\bin\Debug\DB.Interface.dll"); Assembly assemly2 = Assembly.LoadFrom("DB.MySql.dll"); //只要dll 在不会异常,使用的时候,没有依赖项,可能异常 foreach (var item in assemly.GetModules()) //GetModules 得到DLL名称 DB.MySql.dll { Console.WriteLine(item.Name); } foreach (var type in assemly.GetTypes()) //GetTypes { Console.WriteLine(type.Name); foreach (var item in type.GetMethods()) { Console.WriteLine(item.Name); } }