473,383 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Obtaining sub/function name in runtime


Is there a way to find during runtime the name of current sub or


May 15 '06 #1
2 979
"yo***********@gmail.com" <yo***********@gmail.com> wrote:
Is there a way to find during runtime the name of current sub or

Check out StackTrace and StackFrame classes in System.Diagnostics.
Beware of inlining, however, which may result in fewer stack frames than
you expect. Also, collecting stack frame information isn't the fastest
thing in the world, especially if you ship .PDBs and you want line and
file information too.

-- Barry
May 15 '06 #2
Great. I create a new object of type System.Diagnostics.StackFrame and
use its .GetMethod.Name.

Performence is not an issue since I use this for error logging only.


May 15 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: amirmira | last post by:
Hi, I have an application where I monitor the status of a machine using it's IP address. I would like to log an error when the machine goes down - but I want to add the name of the machine along...
by: seannakasone | last post by:
Is there a way to get the callstack level in c++? for example, take the following code: void call3() { //callstack level would be 3 } void call2() { //callstack level would be 2 call3();
by: John Nagle | last post by:
The Python SSL object offers two methods from obtaining the info from an SSL certificate, "server()" and "issuer()". The actual values in the certificate are a series of name/value pairs in ASN.1...
by: psujkov | last post by:
Hi everybody, int f(int a, int b) { return a + b; }; is it possible to obtain this function signature - int (int, int) in this case - for use in boost::function_traits ? e.g. std::cout << "f's...
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.