Reflection - .Net Framework

Table of Contents [Hide/Show]


Names

ItemCode
ProductSystem.Windows.Forms.Application.ProductName
Company1using Microsoft.VisualBasic.ApplicationServices;
using System.Reflection;
AssemblyInfo info = new AssemblyInfo(Assembly.GetExecutingAssembly());
string c2 = info.CompanyName;
Current AssemblyAssembly.GetExecutingAssembly().FullName
Calling Assemblyusing System.Diagnostics;
StackFrame sf = new StackFrame(1);
string result = sf.GetMethod().Module.Assembly.Location;
Current Namespace and ClassMethodInfo.GetCurrentMethod().DeclaringType.FullName
Current MethodMethodInfo.GetCurrentMethod().Name
Current Method, Fully QualifiedMethodInfo info = MethodInfo.GetCurrentMethod();
System.Diagnostics.Debug.Print(info.DeclaringType.FullName + "." + info.Name);
Calling Methodusing System.Diagnostics;
StackFrame sf = new StackFrame(1);
string result = sf.GetMethod().Name;
Calling Method, Fully Qualifiedusing System.Diagnostics;
var mb = new StackTrace().GetFrame(1).GetMethod();
var s = mb.ReflectedType.FullName + "." + mb.Name;

Notes
(1) Be sure to set a reference to Microsoft.VisualBasic.

File Names

ItemCodeNotes
EXE Full NameAssembly.GetExecutingAssembly().LocationReturns the full file name of the current executable, including any file extension.
EXE Full NameApplication.ExecutablePathReturns the full file name of the current executable, including any file extension IN UPPER CASE.

Versions and Other Info

ItemCode
Product VersionSystem.Windows.Forms.Application.ProductVersion
Assembly VersionAssembly.GetExecutingAssembly().GetName().Version.ToString()
Other App Info1using Microsoft.VisualBasic.ApplicationServices;
using System.Reflection;
AssemblyInfo info = new AssemblyInfo(Assembly.GetExecutingAssembly());
// now use properties of the info variable

Notes
(1) Be sure to set a reference to Microsoft.VisualBasic.

Other

Debug Print Current Thread

System.Diagnostics.Debug.Print(
    System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName 
    + "." + 
    System.Reflection.MethodInfo.GetCurrentMethod().Name 
    + " executing on Thread " +
    System.Threading.Thread.CurrentThread.ManagedThreadId.ToString());