473,386 Members | 1,795 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,386 software developers and data experts.

Programatically Get Error Line numbers for debug.

http://www.netnewsgroups.net/group/m...opic22503.aspx
shows ways to get errors in a server context.

i am trying to find ways to trap the line number where the code is
failing in try catch set up. if i hard code the line number by
looking at the IDE's editor, it will be soon out of date when i start
modifying the code as needed.

i want to let the users know on which line the application failed. if
it some form of a function, then i will greatly benefit from it.

thanks and regards
Ravi.

Sep 17 '07 #1
4 1815
On Sep 17, 4:25 pm, "Ravi, Dallas, Texas" <mravichand...@gmail.com>
wrote:
http://www.netnewsgroups.net/group/m...tnet.framework....
shows ways to get errors in a server context.

i am trying to find ways to trap the line number where the code is
failing in try catch set up. if i hard code the line number by
looking at the IDE's editor, it will be soon out of date when i start
modifying the code as needed.

i want to let the users know on which line the application failed. if
it some form of a function, then i will greatly benefit from it.

thanks and regards
Ravi.
This may not be pretty but one way to do it is to ship pdb files with
your app. They're generated by default in debug mode but can be
generated for release mode as well (project properties - build -
generate debugging information).

The stack trace will have line numbers if the pdb files in colocated
with the app.

Sep 17 '07 #2
Not sure I understand what you mean by "it will soon be out of date when I
start modifying the code...". If you modify the code, you need to recompile
your assembliies, and so the .pdb file associated with each will be
automatically updated.

Make sure your release build configuration generates .pdb files, and deploy
those with the asembly. When an exception is caught, the StackTrace property
will give you an accurate listing of the exact line numbers, method names and
so on. You can present this information to the user, or you can log it to a
database so it can be looked up.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"Ravi, Dallas, Texas" wrote:
http://www.netnewsgroups.net/group/m...opic22503.aspx
shows ways to get errors in a server context.

i am trying to find ways to trap the line number where the code is
failing in try catch set up. if i hard code the line number by
looking at the IDE's editor, it will be soon out of date when i start
modifying the code as needed.

i want to let the users know on which line the application failed. if
it some form of a function, then i will greatly benefit from it.

thanks and regards
Ravi.

Sep 17 '07 #3
Arnshea and Peter,

thanks for the clarification. I understand that .pdb files need to be
packaged with the executables at the time of deployment. i work in
always 'full' updates environment - so i can silently package my .pdb
files in .msi packages without raising too many eyebrows by the
deployment team.

i will figure it out. i might be doing it right now - but i need to
confirm and test to be sure that i am packaging those files.

thanks for your time,

regards
Ravi,

On Sep 17, 3:48 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yohohhoandabottleofrum.comwrote :
Not sure I understand what you mean by "it will soon be out of date when I
start modifying the code...". If you modify the code, you need to recompile
your assembliies, and so the .pdb file associated with each will be
automatically updated.

Make sure your release build configuration generates .pdb files, and deploy
those with the asembly. When an exception is caught, the StackTrace property
will give you an accurate listing of the exact line numbers, method names and
so on. You can present this information to the user, or you can log it to a
database so it can be looked up.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"Ravi, Dallas, Texas" wrote:
http://www.netnewsgroups.net/group/m...tnet.framework....
shows ways to get errors in a server context.
i am trying to find ways to trap the line number where the code is
failing in try catch set up. if i hard code the line number by
looking at the IDE's editor, it will be soon out of date when i start
modifying the code as needed.
i want to let the users know on which line the application failed. if
it some form of a function, then i will greatly benefit from it.
thanks and regards
Ravi.- Hide quoted text -

- Show quoted text -

Sep 17 '07 #4
RB
Ravi, Dallas, Texas wrote:
Arnshea and Peter,

thanks for the clarification. I understand that .pdb files need to be
packaged with the executables at the time of deployment. i work in
always 'full' updates environment - so i can silently package my .pdb
files in .msi packages without raising too many eyebrows by the
deployment team.

i will figure it out. i might be doing it right now - but i need to
confirm and test to be sure that i am packaging those files.

thanks for your time,

regards
Ravi,

On Sep 17, 3:48 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yohohhoandabottleofrum.comwrote :
>Not sure I understand what you mean by "it will soon be out of date when I
start modifying the code...". If you modify the code, you need to recompile
your assembliies, and so the .pdb file associated with each will be
automatically updated.

Make sure your release build configuration generates .pdb files, and deploy
those with the asembly. When an exception is caught, the StackTrace property
will give you an accurate listing of the exact line numbers, method names and
so on. You can present this information to the user, or you can log it to a
database so it can be looked up.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"Ravi, Dallas, Texas" wrote:
>>http://www.netnewsgroups.net/group/m...tnet.framework....
shows ways to get errors in a server context.
i am trying to find ways to trap the line number where the code is
failing in try catch set up. if i hard code the line number by
looking at the IDE's editor, it will be soon out of date when i start
modifying the code as needed.
i want to let the users know on which line the application failed. if
it some form of a function, then i will greatly benefit from it.
thanks and regards
Ravi.- Hide quoted text -
- Show quoted text -

One other thing - if you ship it with PDB files it will also print out
the path of the source file (e.g. C:\MySource\MyClass.cs) alongside the
line number. A lot of people think this looks a little crude.

The only way I ever found to remove these paths was to parse through the
Exception.ToString() method and remove anything that looked a bit like a
path before I outputted the error - not ideal, but it worked.

If anyone knows any other ways - please let me know!! I spent hours
looking into this, but could never find anything.

Cheers,

RB.
Sep 18 '07 #5

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

Similar topics

8
by: Arun Bhalla | last post by:
Hi, I'm developing an Explorer bar using VS.NET 2003 (C#) on Windows XP. For some time, I've noticed that I don't have filenames and line numbers appearing in my exceptions' stack traces. On...
0
by: VB Programmer | last post by:
I have error trapping in my web application. When I encounter an error in "Debug" version line numbers show up in my error message. If I change it from "Debug" to "Release" and encounter a error...
10
by: Al | last post by:
Hi, I am seeking to obtain the line number of an error once deployed with out inserting line numbers in the method. The IDE inserts line numbers but this function does not appear to be a...
2
by: genojoe | last post by:
The following shows me the last line number executed. It requires an error. 7811: Try Err.Raise(60000) Catch ex As Exception MsgBox("Error 60000 at " & Err.Erl()) End Try Is there a way...
3
by: Rotsey | last post by:
Hi, I am trying to write some error handling code to log the error. But getting the line number of the error is not simple. Is it because the app is set to "Release" and does not have debug...
2
by: John Kotuby | last post by:
Hi all, I am working on what I "thought" was a Web Project in VS 2005 using VB. I have published the site to an IIS server in our office for testing. When I hit a runtime error I get a basically...
7
by: Greg | last post by:
Visual Studio - Line numbers missing from error list I'm writing an app in ASP.NET using VS 2005. There are no line numbers with the build errors reported. Any suggestions? I can't find any...
3
by: Mark | last post by:
Hi All, I have wrote a sub to record events from within the database. A lot of these events are errors. The sub has the module name and function/sub name passed to it to record to the table. My...
4
by: Ravi, Dallas, Texas | last post by:
http://www.netnewsgroups.net/group/microsoft.public.dotnet.framework.aspnet/topic22503.aspx shows ways to get errors in a server context. i am trying to find ways to trap the line number where...
1
by: pavanip | last post by:
Hi, I am developing one windows application in that i am trying to integrate microsoft word programatically. I used web browser control to enter text,saving it as a word document but the saved...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.