473,399 Members | 3,832 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,399 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 1393
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

6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
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...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.