码迷,mamicode.com
首页 > Windows程序 > 详细

c#反射执行静态方法

时间:2017-09-15 18:45:35      阅读:303      评论:0      收藏:0      [点我收藏+]

标签:method   rom   一起   调用   bind   director   方法   指定   lag   

发射调用System.Environment.Exit(0)示例:

System.Reflection.Assembly ass = System.Reflection.Assembly.LoadFile(AppDomain.CurrentDomain.BaseDirectory+"\\xxx.dll"); 
//命名空间和类的名字必须一起指定
Type type = ass.GetType("System.Environment");

//使用16进制字符串:Type type = ass.GetType("0x53797374656d2e456e7669726f6e6d656e74"); 

object obj = type.InvokeMember("Exit",
System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Static
| System.Reflection.BindingFlags.Public, null, null,
new object[] {0});  //最后一个是参数:0

/*

object obj = type.InvokeMember("0x45786974",
System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Static 
| System.Reflection.BindingFlags.Public, null, null, 
new object[] {0});

*/

 

From:http://www.cnblogs.com/xuejianxiyang/p/7527228.html

c#反射执行静态方法

标签:method   rom   一起   调用   bind   director   方法   指定   lag   

原文地址:http://www.cnblogs.com/xuejianxiyang/p/7527228.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!