Yuri,
Sorry for the long time between replies, I've been busy teaching a training class.
I haven't been able to find a way to display variables that are scoped to just the method you're in when you get the exception (there may be a way, but if so, I don't know what it is), but you can find all public and non-public variables that are scoped to the whole class with the code I originally posted (the ex.TargetSite.ReflectedType.GetMembers() ... use a BindingFlag to narrow what is returned). I don't know if that's enough to help you out though.
~~Bonnie
>Bonnie,
>
>Thanks. I tried digging into ex before posting the original message, but I could not find anything that help. Now, after your response, I tried again, and with the same result. Probably I am missing something.
>
>Let us try this example:
>
> Sub Main()
> Try
>
> Dim lcfile As String = "c:\unknown.txt", _
> lcfile1 As String = "find_me"
>
> If System.IO.File.Exists(lcfile) Then
> System.IO.File.Delete(lcfile)
> End If
>' the line below should initiate the error
> System.IO.File.Open(lcfile, IO.FileMode.Open)
>
> Catch ex As Exception
>' put the breakpoint somewhere below to be able to watch ex in debug mode
> MsgBox(ex.StackTrace)
> MsgBox(ex.Message)
>
> End Try
>
> End Sub
>
>
>
>From the ex.message I assume to get lcfile value, but how to get information about other variables, like lcfile1, and without knowing they exist?
>
>
>>Yuri,
>>
>>I have no experience with listing memory variables, but I found some stuff you could use. Typically I only show the Exception's Message and StackTrace properties, but there are more properties of the Exception class that you could show. I played around with it for a few minutes, and this seemed useful (C# code, but you should be able to get the right VB syntax with no problem):
>>
>>
>>catch (Exception ex)
>>{
>> ex.TargetSite.ReflectedType.GetMembers();
>> // or
>> ex.TargetSite.ReflectedType.GetProperties();
>>}
>>
>>
>>These will produce a lot of stuff you probably don't want to see, but I only suggest it as a starting point. You'll have to see how much of it is useful to you.
>>
>>~~Bonnie
>>
>>
>>
>>
>>>In FoxPro I used to use on error routine having /List MEMORY ... to file/ line. With this I have all memory variables documented as they are at the moment of error.
>>>
>>>Is it possible to implement something similar to this in VB.NET? Could you share your experience? Thanks in advance.