Current Method/Property Information

  • Thread starter Thread starter Mythran
  • Start date Start date
M

Mythran

I would like to display the current method/property information (for
debugging purposes)...

Sub MyMethod()
MsgBox("MyMethod()")
End Sub

Sub MyProperty()
MsgBox("MyProperty")
End Sub


Is there any way to get the name so I don't have to hard code it every time?
Normally I do this type of debugging when I want to see a quick stack trace
w/o using the framework's stack trace (setting up and everything usually
takes a bit...when all I want to see is which event/method is called first).

Hope I explained it good 'nuff....

Thank you in advance..

Mythran
 
Hi Mythran,
Try something like:

Dim current As System.Reflection.MethodBase =
System.Reflection.MethodBase.GetCurrentMethod
System.Diagnostics.Debug.WriteLine(current.Name)
System.Diagnostics.Debug.WriteLine(current.DeclaringType.Name)
System.Diagnostics.Debug.WriteLine(current.DeclaringType.Namespace)

Hope this helps!

Best Regards,

Phil Harvey
 
Phil Harvey said:
Hi Mythran,
Try something like:

Dim current As System.Reflection.MethodBase =
System.Reflection.MethodBase.GetCurrentMethod
System.Diagnostics.Debug.WriteLine(current.Name)
System.Diagnostics.Debug.WriteLine(current.DeclaringType.Name)
System.Diagnostics.Debug.WriteLine(current.DeclaringType.Namespace)

Hope this helps!

Best Regards,

Phil Harvey

Cool, thanks! I'll give it a try! :)

Mythran
 
If all you want to do is see which event/method is called first, put a break
in each event/method and run your application. The point at which the
program breaks is the event/method that was called first.
 
Not a bad idea, problem is, we don't want to break...we want to see the form
running and what is going on during execution on the form (graphic-wise) so
breaking would prevent us from seeing that.

Mythran
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top