Hi I am searching for a method like this
GetObjectByStringReference(ObjectName as string) as object

E.g.

Dim var1 as string = "Test"

Dim O as object = GetObjectByStringReference("var1")
Console.writeline("Value of O:" & O.ToString())

Should Output Test

I need this to get detailed error logging information from my methods.

I can get the Argument names my this code
Dim _methodif As Reflection.MethodInfo =
Reflection.MethodInfo.GetCurrentMethod
Dim _param() As Reflection.ParameterInfo = _methodif.GetParameters()

For Each _pi As ParameterInfo In _param
MessageBox.Show(_pi.Name)
Next

What I need is to get the object reference of a variable by the name
of the variable.

I would figure that the databinding in asp.net does this?

Please help..

Re: Reflection GetObjectByStringReference(string) as object by Jon

Jon
Mon Apr 18 16:16:08 CDT 2005

Andre <andresl132@hotmail.com> wrote:
> Hi I am searching for a method like this
> GetObjectByStringReference(ObjectName as string) as object
>
> E.g.
>
> Dim var1 as string = "Test"
>
> Dim O as object = GetObjectByStringReference("var1")
> Console.writeline("Value of O:" & O.ToString())
>
> Should Output Test
>
> I need this to get detailed error logging information from my methods.
>
> I can get the Argument names my this code
> Dim _methodif As Reflection.MethodInfo =
> Reflection.MethodInfo.GetCurrentMethod
> Dim _param() As Reflection.ParameterInfo = _methodif.GetParameters()
>
> For Each _pi As ParameterInfo In _param
> MessageBox.Show(_pi.Name)
> Next
>
> What I need is to get the object reference of a variable by the name
> of the variable.
>
> I would figure that the databinding in asp.net does this?

Not if var1 is a local variable. By the time it gets as far as
execution, the JIT may not even know that it ever had a name.

For instance variables, you can use reflection, but you can't get the
value of a local variable with reflection.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too