jinyuttt

导航

2011年5月24日

映射获取调用方法的方法名称c#

摘要: using System.Diagnostics;using System.Reflection;StackTrace ss = new StackTrace(true);string t =ss.GetFrame(2).GetMethod().DeclaringType.ToString()+"."+ss.GetFrame(2).GetMethod().Name; return t;获取2级调用的方法名称,GetFrame(index),index的值讲影响获取的层级方法。StackTrace ss = new StackTrace(true); string t = s 阅读全文

posted @ 2011-05-24 16:46 代码苦行僧 阅读(553) 评论(0) 推荐(1) 编辑

利用C#的反射机制动态调用DLL类库

摘要: 1、使用Assembly类定义和加载程序集,加载在程序集清单中列出模块,以及从此程序集中查找类型并创建该类型的实例。2、使用MethodInfo了解方法的名称、返回类型、参数、访问修饰符(如pulic 或private)和实现详细信息(如abstract或virtual)等。使用Type的GetMethods或GetMethod方法来调用特定的方法。一、创建用于反射调用的DLLusing System;using System.Collections.Generic;using System.Text;namespace RefDll{ /// <summary> /// 创建需要 阅读全文

posted @ 2011-05-24 16:31 代码苦行僧 阅读(1660) 评论(0) 推荐(0) 编辑