TechTalkz.com Logo Ask the Experts!

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Programing Languages > C#(C Sharp)

Programatically Get Error Line numbers for debug.

C#(C Sharp)

 
 
 
Thread Tools Display Modes
Old 17-09-2007, 09:04 PM   #1
Ravi, Dallas, Texas
Guest
 
Posts: n/a
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.

 
Old 17-09-2007, 09:04 PM   #2
Arnshea
Guest
 
Posts: n/a
Re: Programatically Get Error Line numbers for debug.

On Sep 17, 4:25 pm, "Ravi, Dallas, Texas" <mravichand...***********>
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.

 
Old 17-09-2007, 09:04 PM   #3
Peter Bromberg [C# MVP]
Guest
 
Posts: n/a
RE: Programatically Get Error Line numbers for debug.

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

 
Old 17-09-2007, 10:06 PM   #4
Ravi, Dallas, Texas
Guest
 
Posts: n/a
Re: Programatically Get Error Line numbers for debug.

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.com> wrote:
> 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 -



 
Old 18-09-2007, 09:01 AM   #5
RB
Guest
 
Posts: n/a
Re: Programatically Get Error Line numbers for debug.

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.com> wrote:
>> 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.
 
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
line with numbers vinnie C#(C Sharp) 1 05-09-2007 09:09 AM
A Runtime Error has occurred. Do you wish to Debug? M Skabialka Internet Explorer 18 28-08-2007 09:11 PM
A Runtime Error has occurred. Do you wish to Debug? M Skabialka Internet Explorer 0 28-08-2007 07:50 PM
A Runtime Error has occurred. Do you wish to Debug? M Skabialka Internet Explorer 2 28-08-2007 07:50 PM
Galaxy Debug Error Terry Windows XP 0 21-08-2007 05:16 AM


< Home - Windows Help - MS Office Help - Hardware Support >


New To Site? Need Help?

All times are GMT. The time now is 10:36 PM.


vBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2013, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional