473,386 Members | 1,803 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,386 software developers and data experts.

Getting the name of the cuurent function

Is there a way to get the name of the current function?

I have an error routine that emails me information on failing application,
function and error info. Right now I am entering the function name by hand
into each call to the error routine but I would like to standardize things
by pulling this info "out of the air".

Is this doable?
Any help is greatly appreciated.
Nov 17 '05 #1
4 1070
use reflection.
"Greg Smith" <gj*@umn.edu> wrote in message
news:Oz**************@TK2MSFTNGP09.phx.gbl...
Is there a way to get the name of the current function?

I have an error routine that emails me information on failing application,
function and error info. Right now I am entering the function name by
hand into each call to the error routine but I would like to standardize
things by pulling this info "out of the air".

Is this doable?
Any help is greatly appreciated.

Nov 17 '05 #2
Greg,

Use Environment.StackTrace:

http://msdn.microsoft.com/library/de...tracetopic.asp

If your function is gonna be used as an exception handler, you can use the
Exception.StackTrace property:

http://msdn.microsoft.com/library/de...tracetopic.asp

Regards - Octavio

"Greg Smith" <gj*@umn.edu> escribió en el mensaje
news:Oz**************@TK2MSFTNGP09.phx.gbl...
Is there a way to get the name of the current function?

I have an error routine that emails me information on failing application,
function and error info. Right now I am entering the function name by
hand into each call to the error routine but I would like to standardize
things by pulling this info "out of the air".

Is this doable?
Any help is greatly appreciated.

Nov 17 '05 #3
Hi,

Check out the code @:
http://msmvps.com/rakeshrajan/archiv.../02/45408.aspx

This code returns the calling method. Since you need the current method,
change st.GetFrame(1) to st.GetFrame(0) in the code and you are good to go.

--
HTH,
Rakesh Rajan
MVP, MCSD
http://www.msmvps.com/rakeshrajan/

"Greg Smith" wrote:
Is there a way to get the name of the current function?

I have an error routine that emails me information on failing application,
function and error info. Right now I am entering the function name by hand
into each call to the error routine but I would like to standardize things
by pulling this info "out of the air".

Is this doable?
Any help is greatly appreciated.

Nov 17 '05 #4
MethodBase.GetCurrentMethod().Name should do the trick.

Regards
Senthil

Nov 17 '05 #5

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

Similar topics

2
by: Eyal | last post by:
Hey, I would appriciate if anyone can help on this one: I have a java object/inteface having a method with a boolean parameter. As I'm trying to call this method from a javascript it fails on...
4
by: gimme_this_gimme_that | last post by:
Hi, This is sort of a : How to build a Yes/No dialog box qquestion. Or perhaps a question about getting javascript variables from a pop-up window and processing them on a submit. This is...
1
by: kamleshsharmadts | last post by:
I am using Ajax with struts in web application. from jsp i am calling a function of ajax.js onclick of a button. code of that call function which calling from jsp given as below:- ...
1
by: simbarashe | last post by:
Hie could someone please help me with getting and using the current page url. I have a function that gets the url, I want to use it with header(location : XXX) but it wont work. The code is as...
4
by: =?Utf-8?B?QUEyZTcyRQ==?= | last post by:
Why does System.Globalization.DateTimeFormatInfo.CurrentInfo.MonthNames return 13 elements? Why does it not use the cuurent culture?
1
by: raghuvendra | last post by:
Hi I have a jsp page with 4 columns: namely Category name , Category order, Input field and a submit button. All these are aligned in a row. And Each Category Name has its corresponding Category...
5
by: tshad | last post by:
I have the following class in my VS 2008 project that has a namespace of MyFunctions. ********************************* Imports System Imports System.Text.RegularExpressions Namespace...
9
Catalyst159
by: Catalyst159 | last post by:
I have a form which is used to calculate residential Floor Area Ratio (FAR). The form is structured into seven parts as follows: Part A: Maximum FAR and Floor Area: Part B: Gross Floor Area of...
7
vikas251074
by: vikas251074 | last post by:
I am getting error above in following code since few days giving tension day and night. How can I solve this? I am facing since Oct.25. in line no. 362 After doing a lot of homework, I am...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
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...
0
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
0
BarryA
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...
1
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...
0
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.