Results 1 to 3 of 3

Thread: Object that Stores Function/Sub name

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2001
    Posts
    107

    Cool Object that Stores Function/Sub name

    For debugging purposes, is there an object I can reference that stores a Function/Sub name?

    In the process of returning values and tracking the flow of control between classes/projects I want to simply build a string as each function is exited.

    Thanks,
    Miguel

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    There is only 1 place I know of you can do this without manually setting them. Within you Catch block for errors, you can use the TargetSite property of the Exception object to get the routine the exception occured in.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You may be able to get it from the stacktrace. I've seen code to find out why a form is closing that checks method names in the stacktrace. It starts like this to get the info:
    VB Code:
    1. Dim O As New System.Diagnostics.StackTrace(True)
    2.         Dim F As System.Diagnostics.StackFrame
    3.  
    4.         F = O.GetFrame(8)
    5.  
    6.         Select Case F.GetMethod.Name.ToString
    7.             Case "SendMessage"
    8.                 'Closing because of call in code
    9.                 Return QueryUnloadModes.CodeCall
    10.             Case "CallWindowProc"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width