Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Page History: Reflection - .Net Framework

Compare Page Revisions



« Older Revision - Back to Page History - Newer Revision »


Page Revision: Thu, Oct 08, 2009, 9:21 AM


Table of Contents [Hide/Show]


      Application Product Name
      Application Version
      EXE Full Name
      Other App Info
      Company Name
      Current Assembly Name
      Current Namespace and Class Name
      Current Procedure Name
      Current Procedure Name, Fully Qualified
         VB.NET
         C#
      Calling Method
      Calling Assembly
      Debug Print Current Thread


Application Product Name

System.Windows.Forms.Application.ProductName

Application Version

System.Windows.Forms.Application.ProductVersion

EXE Full Name

This will return the full file name of the current executable, including any file extension. Note that this returns the same as Application.ExecutablePath, except that Application.ExecutablePath returns the file extension in upper case.
System.Reflection.Assembly.GetExecutingAssembly().Location

Other App Info

Be sure to set a reference to Microsoft.VisualBasic.
using Microsoft.VisualBasic.ApplicationServices;
using System.Reflection;
AssemblyInfo info = new AssemblyInfo(Assembly.GetExecutingAssembly());
// now use properties of the info variable

Company Name

Be sure to set a reference to Microsoft.VisualBasic.
using Microsoft.VisualBasic.ApplicationServices;
using System.Reflection;
AssemblyInfo info = new AssemblyInfo(Assembly.GetExecutingAssembly());
string c2 = info.CompanyName;

Current Assembly Name

System.Reflection.Assembly.GetExecutingAssembly().FullName

Current Namespace and Class Name

System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName

Current Procedure Name

System.Reflection.MethodInfo.GetCurrentMethod().Name

Current Procedure Name, Fully Qualified

VB.NET

Dim info As System.Reflection.MethodInfo = System.Reflection.MethodInfo.GetCurrentMethod()
System.Diagnostics.Debug.Print(info.DeclaringType.FullName & "." & info.Name)

C#

System.Reflection.MethodInfo info = System.Reflection.MethodInfo.GetCurrentMethod();
System.Diagnostics.Debug.Print(info.DeclaringType.FullName + "." + info.Name);

Calling Method

System.Diagnostics.StackFrame sf = new System.Diagnostics.StackFrame(1);
string result = sf.GetMethod().Name;

Calling Assembly

StackFrame sf = new System.Diagnostics.StackFrame(1);
string result = sf.GetMethod().Module.Assembly.Location;

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());

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.