水如烟

                 顺其自然,水到渠成 LzmTW

文或代码皆是面向初学者.我是爱好者,也是初学者.那些"文章",只按自己理解写,我是不知术语名词的.所以只供参考,也仅供参考.

导航

HOW TO:获取执行代码所处环境信息(小结)

Posted on 2006-08-16 21:46  水如烟(LzmTW)  阅读(232)  评论(0编辑  收藏  举报

一般是静态方法

一、程序域

System.AppDomain.CurrentDomain

二、程序集

程序入口
System.Reflection.Assembly.GetEntryAssembly()

当前方法所在
System.Reflection.Assembly.GetExecutingAssembly()

当前方法的调用者方法所在
System.Reflection.Assembly.GetCallingAssembly()

三、当前方法
System.Reflection.MethodBase.GetCurrentMethod()

还可以从实例中找
Dim mStackFrame As New System.Diagnostics.StackFrame
mStackFrame.GetMethod()

Dim mStackTrace As New System.Diagnostics.StackTrace
For Each mStackFrame As System.Diagnostics.StackFrame In mStackTrace.GetFrames
    mStackFrame.GetMethod()
Next

四、其它,当前进程
System.Diagnostics.Process.GetCurrentProcess()