Looping through variables

nismo

Member
Joined
Jun 30, 2006
Messages
18
Programming Experience
3-5
In order to provide the ultimate in error reporting for our application, is there any way in VB.NET that i can do a loop which loops around every variable currently in memory and be able to return the name and its value?
 
Having a snapshot of variables is usually not that effective.. The stacktrace of the exception is usually far more helpful. Reflection should be able to do what you require, though beware that the overhead is significant
 
Well, the stack trace rarely ever helps me because it doesnt contain a line number and my functions are large.

Since the user can rarely explain what they were doing very well, having a snapshot of the variables would be incredibly useful.

I appreciate the reply, but are you able to help me out a bit more? I mean, how exactly would i use the reflection namespace to get a snapshot, and how much overhead are we talking here?
 
Well, the stack trace rarely ever helps me because it doesnt contain a line number
Compiled code doesnt comprise "lines"

and my functions are large.
It is usually advised to avoid such a programming style

Since the user can rarely explain what they were doing very well, having a snapshot of the variables would be incredibly useful.
Structured try/catching and logging of significant events would be my approach..

I appreciate the reply, but are you able to help me out a bit more? I mean, how exactly would i use the reflection namespace to get a snapshot, and how much overhead are we talking here?
I dont know for certain; in 10 years of OO, i've never really had need for reflection. Sorry!
 
Back
Top