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: Wed, Dec 30, 2009, 10:17 AM


Table of Contents [Hide/Show]


Names

ItemCode
Application Product NameSystem.Windows.Forms.Application.ProductName
Company Name1using Microsoft.VisualBasic.ApplicationServices;
using System.Reflection;
AssemblyInfo info = new AssemblyInfo(Assembly.GetExecutingAssembly());
string c2 = info.CompanyName;
Current Assembly NameAssembly.GetExecutingAssembly().FullName
Current Namespace and Class NameMethodInfo.GetCurrentMethod().DeclaringType.FullName
Current Procedure NameMethodInfo.GetCurrentMethod().Name
Current Procedure Name, 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 Assemblyusing System.Diagnostics;
StackFrame sf = new StackFrame(1);
string result = sf.GetMethod().Module.Assembly.Location;

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.

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.