Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / July 2004

Tip: Looking for answers? Try searching our database.

Determine calling method from within called method?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ben Fidge - 23 Jul 2004 15:24 GMT
From within a method of a class, how do you determine the
name of the class.method that called it, programmatically?

I have a log file class, and it would be very beneficial
to be able store the name of the class and method that
called my LogFile.Write method.

Kind regards

Ben
Christopher Wells - 23 Jul 2004 16:33 GMT
> From within a method of a class, how do you determine the
> name of the class.method that called it, programmatically?

Perhaps the System.Diagnostics.StackTrace class is what you want.
Sridhar - 23 Jul 2004 22:00 GMT
Hi,

 May be You can use

     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType which will give the class name from which it is called.

Sridhar!!

> From within a method of a class, how do you determine the
> name of the class.method that called it, programmatically?
[quoted text clipped - 6 lines]
>
> Ben
Ahmed AbouTaleb - 26 Jul 2004 17:01 GMT
You can use System.Diagnostics.StackTrace to get the calling method using
GetFrame method.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.