Solved

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

Posted on 2004-09-13
2
1,035 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

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
.NET 2008 VB and C# 6 48
how to remove duplicate code from my project 5 49
ASP.NET - Why is accordion not working? 3 49
C# XML Get Values 4 35
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 a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

733 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