473,320 Members | 1,991 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Current namespace, stack and lineno

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

Aug 25 '06 #1
3 1472
Hello markroworth,

Check out the StackTrace and Exception classes.

-Boo
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

Aug 25 '06 #2
markroworth wrote:
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.
Aug 25 '06 #3
Thanks guys, that's solved my problems.

Phill W. wrote:
markroworth wrote:
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.
Aug 26 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: Bo Peng | last post by:
Dear list, I have many dictionaries with the same set of keys and I would like to write a function to calculate something based on these values. For example, I have a = {'x':1, 'y':2} b =...
3
by: Kelmen Wong | last post by:
Greeting, I'm working on a class managing resources (satelite). public CResMgr() { Assembly objClient = Assembly.GetCallingAssembly(); _objResMgr = new...
8
by: Douglas | last post by:
**** Post for FREE via your newsreader at post.usenet.com **** Hello, The following code does not compile if line 3 is uncommented "using namespace std". I do not understand it. Could...
11
by: Ken Varn | last post by:
I want to be able to determine my current line, file, and function in my C# application. I know that C++ has the __LINE__, __FUNCTION__, and __FILE___ macros for getting this, but I cannot find a...
3
by: Nirbho | last post by:
Hi, I'm newish to C# .Net. I'm doing some error handling in my ASP.net pages. When handling the error in the catch block, I want to pass through the namespace of where the error occured.....
3
by: namewitheldbyrequest | last post by:
"The XML element 'EnableTheming' from namespace 'http://tempuri.org/' is already present in the current scope" I created a Web Service: I imported System.Data.SqlClient so I could access SQL...
0
by: Andre Poenitz | last post by:
Bear with me - I am new to Python. (And redirect me to a more suitable newsgroup in case this one is not appropriate.) I am trying to embed Python into a C++ application and want to get back a...
0
by: Durango2008 | last post by:
Hi I am having a hard time with validation of my XML file with given schema. Here are the files: roboerrorlog.xsd <robomss:schema xmlns:robomss="http://www.w3.org/2001/XMLSchema"...
1
by: Laszlo Nagy | last post by:
I'm sorry for the dumb question. I had to add these to the lexer: def t_comment(t): r"\#*\n" t.lexer.lineno += 1 # We do not return anything - comments are ignored. # Define a rule so we can...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.