How can i know where instance of class was created?

Hi,
i have my own Exception class, i want to add to error message source class which create  instance of exception.

    public class Konektor_Exception : Exception
    {       
        public string Message_Konektor;
        public Konektor_Exception(string paMessage):base(source_class)   
        {         
            this.Message_Konektor = paMessage;
        }
    }
----
in code base(source_class),
source_class = string of author class of  instance of  Exception...
how can i do it



Answer this question

How can i know where instance of class was created?

  • Jerry2000

    Hello.

    this.Source - this is ok

    other thing is that you can navigate trough execution stack.

    Here code to get previous method:
    System.Diagnostics.StackTrace stack = new System.Diagnostics.StackTrace(0);
    MethodInfo causingMethod = (MethodInfo)stack.GetFrame(1).GetMethod();

  • How can i know where instance of class was created?