Current namespace, stack and lineno

M

markroworth

Hi everyone,

I'm relatively new to vb.net and am writing my errors object to collect
errors as the call stack bounces back up to the GUI. When an error
occurs, I would like to grab three things:

1. the line no the error occurred on
2. the current namespace. e.g. MyApplication.MyClass.MyFunction
3. the callstack.

Does anyone know how to do this. Also, having transferred over recently
from VB6, is there any way to query as in the immediate window of VB6
at runtime. Or for that matter, change the code at runtime (in the dev
environment, obviously).

Any information very gratefully received. Many thanks,

Mark Roworth
 
P

Phill W.

markroworth said:
When an error occurs, I would like to grab three things:

1. the line no the error occurred on
2. the current namespace. e.g. MyApplication.MyClass.MyFunction
3. the callstack.

Try
SomethingIffy()

Catch ex As System.Exception
Console.Writeline( ex.ToString() )

End Try

The Exception class has lots of useful properties that you can use to
pull the error apart (StackTrace and Message being the most useful).
is there any way to query as in the immediate window of VB6
at runtime.

There's an Immediate Window in Visual Basic ('2002, '2003 and '2005 -
you didn't say which one you're using).
Or for that matter, change the code at runtime

"Edit and Continue" is back in VB'2005 (for Console and Forms app's,
anyway) but there have been /many/ reports of [*very*] poor performance
when debugging with it switched on.
That /may/ [have] improve[d] with SP1 (is that out yet?); I can't
confirm/deny this.

HTH,
Phill W.
 
M

markroworth

Thanks guys, that's solved my problems.
markroworth said:
When an error occurs, I would like to grab three things:

1. the line no the error occurred on
2. the current namespace. e.g. MyApplication.MyClass.MyFunction
3. the callstack.

Try
SomethingIffy()

Catch ex As System.Exception
Console.Writeline( ex.ToString() )

End Try

The Exception class has lots of useful properties that you can use to
pull the error apart (StackTrace and Message being the most useful).
is there any way to query as in the immediate window of VB6
at runtime.

There's an Immediate Window in Visual Basic ('2002, '2003 and '2005 -
you didn't say which one you're using).
Or for that matter, change the code at runtime

"Edit and Continue" is back in VB'2005 (for Console and Forms app's,
anyway) but there have been /many/ reports of [*very*] poor performance
when debugging with it switched on.
That /may/ [have] improve[d] with SP1 (is that out yet?); I can't
confirm/deny this.

HTH,
Phill W.
 

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

Top