From: (PeteCresswell) on
Are line numbers in VB.NET coding totally passe'?

I've used them for years in VBA coding. My error trapping
writes the error and line number to a .txt file and it's been
very helpful in speeding up the process of finding/fixing errors.

Or is there some functional equivalent in the .NET scheme of
things?
--
PeteCresswell
From: Scott M. on

"(PeteCresswell)" <x(a)y.Invalid> wrote in message
news:65r4i5degihhkm1apulj5tgt8gao82gmln(a)4ax.com...
> Are line numbers in VB.NET coding totally passe'?
>
> I've used them for years in VBA coding. My error trapping
> writes the error and line number to a .txt file and it's been
> very helpful in speeding up the process of finding/fixing errors.
>
> Or is there some functional equivalent in the .NET scheme of
> things?
> --
> PeteCresswell

VBA is not compiled code like .NET is. When you get a runtime error in a
VBA app., you can go straight to that line and see what's going on. When
you get an exception in a .NET applicaiton at runtime, you're getting an
exception in the compiled Intermediate Language code that is being processed
by the CLR, not from the source code per se.

In .NET, when you realize that you have runtime exceptions, you first need
to know what assembly they are eminating from and then the stacktrace of the
exception will give you guidance as to what part of the code was being
executed when the exception occured.

In general, you can use Try...Catch blocks around code that *may* break at
runtime and you can then log your exceptions by looking at the exception's:
name, type, innerException, and stacktrace.

-Scott


From: Mr. Arnold on
(PeteCresswell) wrote:
> Are line numbers in VB.NET coding totally passe'?
>
> I've used them for years in VBA coding. My error trapping
> writes the error and line number to a .txt file and it's been
> very helpful in speeding up the process of finding/fixing errors.
>
> Or is there some functional equivalent in the .NET scheme of
> things?

You do a Stack Trace in the error trapping code in .NET for VB or C#
code, it will give the class name and the line number in the class where
the error occurred when using try/catch is being used.


You may also need Inner Exception message along with the Stack Trace.

http://www.java2s.com/Tutorial/VB/0140__Development/UsepropertiesMessageStackTraceandInnerException.htm
From: (PeteCresswell) on
Per Mr. Arnold:
>
>You do a Stack Trace in the error trapping code in .NET for VB or C#
>code, it will give the class name and the line number in the class where
>the error occurred when using try/catch is being used.

I think it's starting to soak in.

Is it common practice to have a single error handling routine
that is called by "Catch" - and which writes relevant info to a
..txt file?
--
PeteCresswell
From: (PeteCresswell) on
Per (PeteCresswell):
>Is it common practice to have a single error handling routine...

I retract that question. Seems tb a *lot* of stuff out there on
error handling... e.g.
http://www.codeproject.com/KB/architecture/exceptionbestpractices.aspx#Don%27tthrownewException%28%297
--
PeteCresswell