Solved

in C# dll, how to know the calling method's name?

Posted on 2004-09-13
2
1,029 Views
Last Modified: 2008-03-06
I know how to get the calling app's name from the body of the C# dll, but how do i find out that which mehtod of the client app is calling the method of the DLL?

The dll is a common class libary created in C#. Calling app is also created in C#

Thanks!
0
Comment
Question by:cliffairal
  • 2
2 Comments
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 12047867
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 250 total points
ID: 12047912
using System;
using System.Diagnostics;
namespace ConsoleApplication28
{
      /// <summary>
      /// Summary description for Class1.
      /// </summary>
      class Class1
      {

            private static void TestMethod(int i) {
                  StackFrame sf = new StackFrame(1);
                  StackTrace st = new StackTrace(sf);
                  for(int j=0;j<st.FrameCount;j++) {
                        Console.WriteLine("Method name - " + st.GetFrame(j).GetMethod().Name);
                        Console.WriteLine(st.GetFrame(j).GetMethod().ToString());
                  }      
            }

            [STAThread]
            static void Main(string[] args)
            {
                  try {
                        TestMethod(0);
                  }
                  catch (Exception Ex) {
                        Console.WriteLine(Ex.ToString());
                  }
            }
      }
}
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now