Solved

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

Posted on 2004-09-13
2
1,037 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

707 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