473,327 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Current Method/Property Information

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
Nov 21 '05 #1
5 994
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.Declari ngType.Name)
System.Diagnostics.Debug.WriteLine(current.Declari ngType.Namespace)

Hope this helps!

Best Regards,

Phil Harvey

--------------------
http://spaces.msn.com/members/dotnetspace
Nov 21 '05 #2

"Phil Harvey" <ph***@teamlink.it> wrote in message
news:Og*************@TK2MSFTNGP10.phx.gbl...
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.Declari ngType.Name)
System.Diagnostics.Debug.WriteLine(current.Declari ngType.Namespace)

Hope this helps!

Best Regards,

Phil Harvey

--------------------
http://spaces.msn.com/members/dotnetspace


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

Mythran
Nov 21 '05 #3
No problem :D

Phil
Nov 21 '05 #4
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.

"Mythran" wrote:
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

Nov 21 '05 #5
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

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:D7**********************************@microsof t.com...
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.

"Mythran" wrote:
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

Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
11
by: Ken Varn | last post by:
I want to be able to determine my current line, file, and function in my C# application. I know that C++ has the __LINE__, __FUNCTION__, and __FILE___ macros for getting this, but I cannot find a...
2
by: Francois Malgreve | last post by:
hello guys, I have some helper class in my ASP.NET pplication who basically contains static methods. I used them as helper methods to do small jobs that I can use at many places in my code. ...
7
by: Brian Henry | last post by:
Hi, I have a data grid that has the following properties EnableViewState = false AllowPaging = true AllowSorting = true AllowCustomPaging = false now, when the page switches I want to get...
15
by: Jason | last post by:
Currently, I am storing information about the currently logged on user in Session variables that are stored in SQL. However, I am using role-based security, so I am storing custom roles in a...
8
by: news.microsoft.com | last post by:
How do I get the class name for a current instance. For example, if I want to know the Class Name for the current form, how do I get this programatically. Thanks
1
by: Guido Kraus | last post by:
Hi, I wonder how to get the name of the currently executing property by using reflection in .Net 2.0 If I use System.Reflection.MethodInfo.GetCurrentMethod().Name from within a property I get...
3
by: namewitheldbyrequest | last post by:
"The XML element 'EnableTheming' from namespace 'http://tempuri.org/' is already present in the current scope" I created a Web Service: I imported System.Data.SqlClient so I could access SQL...
3
by: Bob Cohen \(106531\) | last post by:
I want to define some metadata using custom attributes to apply to properties in various classes. The properties return values that are classes themselves. I want to retrieve the attribute...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.