Reflection Related Quesitons

  • Thread starter Thread starter Hayato Iriumi
  • Start date Start date
H

Hayato Iriumi

(1) Can custom attribute be assigned to a class (or other elements) at
runtime? I tried to use MethodInfo to do that, but it doesn't seem to be
possible...

(2) Can I get the name of the method that is currently running? The example
follows...

Sub MyMethod()
Dim strMethodName As String = System.Reflection.Assembly.blahblah...
Console.WriteLine("The name of the method that is currently runnning is
{0}",strMethodName)
End Sub

TIA
 
(1) Can custom attribute be assigned to a class (or other elements) at
runtime? I tried to use MethodInfo to do that, but it doesn't seem to be
possible...

Only to types dynamicly created with Reflection Emit, not existing
compiled code.

(2) Can I get the name of the method that is currently running?

System.Reflection.MethodBase.GetCurrentMethod().Name



Mattias
 
----- Hayato Iriumi wrote: ----

I'm not really sure I understand what you'd do this for. Could you give a hint as to what you're trying to accomplish here


Either of these will get you the name of the currently executing method

new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name
System.Reflection.MethodInfo.GetCurrentMethod().Name
 
Say, the values I want to asssign to the attribute are stored in
database...

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 

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