Retrieve name of Function, Sub, Class, Property etc from within that item during runtime
Author |
Message |
sln #1 / 5
|
 Retrieve name of Function, Sub, Class, Property etc from within that item during runtime
We are writing a system that requires us to programattically determine the name of the: 1. Sub 2. Function 3. Method 4. Class 5. Form 6. Module 7. etc during runtime, while executing code within that area. The name will be used for internal and reporting purposes. How can we do this? sln
|
Wed, 07 Dec 2005 21:56:12 GMT |
|
 |
Jerr #2 / 5
|
 Retrieve name of Function, Sub, Class, Property etc from within that item during runtime
Some things you can do with reflection. Search for "reflection" in the Web
Quote: > We are writing a system that requires us to programattically determine the > name of the: > 1. Sub > 2. Function > 3. Method > 4. Class > 5. Form > 6. Module > 7. etc > during runtime, while executing code within that area. The name will be > used for internal and reporting purposes. > How can we do this? > sln
|
Wed, 07 Dec 2005 22:34:14 GMT |
|
 |
sln #3 / 5
|
 Retrieve name of Function, Sub, Class, Property etc from within that item during runtime
Thanks, but that does not give me the answer as to how to find out the name of the routine I am currently in. IE how do I reference the name of the sub, function, class, method, property, etc... during runtime. I understand that reflection namespace may be helpfull, but I'm looking for how do it. Can anyone help? sln
Quote: > Some things you can do with reflection. > Search for "reflection" in the Web
> > We are writing a system that requires us to programattically determine the > > name of the: > > 1. Sub > > 2. Function > > 3. Method > > 4. Class > > 5. Form > > 6. Module > > 7. etc > > during runtime, while executing code within that area. The name will be > > used for internal and reporting purposes. > > How can we do this? > > sln
|
Thu, 08 Dec 2005 00:21:24 GMT |
|
 |
Jerr #4 / 5
|
 Retrieve name of Function, Sub, Class, Property etc from within that item during runtime
Quote: >>find out the name of the routine I am currently in.
Take a look at the "StackTrace" maybe this will help you. dim currentStack as string currentStack = System.Environment.StackTrace
Quote: > Thanks, but that does not give me the answer as to how to find out the name > of the routine I am currently in. IE how do I reference the name of the > sub, function, class, method, property, etc... during runtime. I understand > that reflection namespace may be helpfull, but I'm looking for how do it. > Can anyone help? > sln
> > Some things you can do with reflection. > > Search for "reflection" in the Web
> > > We are writing a system that requires us to programattically determine > the > > > name of the: > > > 1. Sub > > > 2. Function > > > 3. Method > > > 4. Class > > > 5. Form > > > 6. Module > > > 7. etc > > > during runtime, while executing code within that area. The name will be > > > used for internal and reporting purposes. > > > How can we do this? > > > sln
|
Thu, 08 Dec 2005 19:58:45 GMT |
|
 |
Felix Wu [MSF #5 / 5
|
 Retrieve name of Function, Sub, Class, Property etc from within that item during runtime
Hi snesbit, Jerry is right. We can do this by using the Reflection mechanism in .NET. Fortunately, .NET provides you with a handy class called MethodBase. It gives you entries to get the information about a method at runtime. You can also retrieve the information about the class that declares the method by using the DeclaringType method on the MethodBase instance. It returns a Type object, with which you get all kinds of information about the type and the assembly that contains this type as well. For more information about the class MethodBase, please refer to the MSDN documentation. Regards, Felix Wu ============= This posting is provided "AS IS" with no warranties, and confers no rights. --------------------
| Subject: Re: Retrieve name of Function, Sub, Class, Property etc from within that item during runtime | Date: Sat, 21 Jun 2003 12:21:24 -0400 | Lines: 46 | X-Priority: 3 | X-MSMail-Priority: Normal | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Newsgroups: microsoft.public.dotnet.framework.windowsforms,microsoft.public.dotnet.frame work.windowsforms.controls,microsoft.public.dotnet.languages.vb | NNTP-Posting-Host: pcp819229pcs.nrockv01.md.comcast.net 68.49.48.203 | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl | Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.windowsforms.controls:9010 microsoft.public.dotnet.languages.vb:115625 microsoft.public.dotnet.framework.windowsforms:47003 | X-Tomcat-NG: microsoft.public.dotnet.languages.vb | | Thanks, but that does not give me the answer as to how to find out the name | of the routine I am currently in. IE how do I reference the name of the | sub, function, class, method, property, etc... during runtime. I understand | that reflection namespace may be helpfull, but I'm looking for how do it. | | Can anyone help? | | | sln |
| > | > Some things you can do with reflection. | > | > Search for "reflection" in the Web | >
| > > We are writing a system that requires us to programattically determine | the | > > name of the: | > > | > > 1. Sub | > > 2. Function | > > 3. Method | > > 4. Class | > > 5. Form | > > 6. Module | > > 7. etc | > > | > > | > > during runtime, while executing code within that area. The name will be | > > used for internal and reporting purposes. | > > | > > How can we do this? | > > | > > sln | > > | > > | > > | > > | > | > | | |
|
Fri, 09 Dec 2005 17:17:52 GMT |
|
|
|