473,386 Members | 1,752 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.

How to get the line number of an exception?

Hi,

Am trying to be able to the line number of an exception.

The stack trace is not showing it.

rotsey
Oct 3 '06 #1
6 3050
Should be available from the Exception.StackTrace property:
http://msdn2.microsoft.com/en-us/lib...tacktrace.aspx

What type of exception is being thrown? Maybe the stack trace isn't
being set properly for some reason.

Rotsey wrote:
Hi,

Am trying to be able to the line number of an exception.

The stack trace is not showing it.

rotsey
Oct 3 '06 #2
Should be available from the Exception.StackTrace property:
http://msdn2.microsoft.com/en-us/lib...tacktrace.aspx

What type of exception is being thrown? Maybe the stack trace isn't
being set properly for some reason.
Is that available *always*? I thought linenumber-info was only
available when there is a .pdb file present for the dll where the error
is? (Read: when it has been compiled in DEBUG mode.)

Hans Kesting
Rotsey wrote:
>Hi,

Am trying to be able to the line number of an exception.

The stack trace is not showing it.

rotsey

Oct 3 '06 #3
On Tue, 03 Oct 2006 12:03:57 +0200, Hans Kesting
<ne***********@spamgourmet.comwrote:
Is that available *always*? I thought linenumber-info was only available
when there is a .pdb file present for the dll where the error is? (Read:
when it has been compiled in DEBUG mode.)
Line number is available in DEBUG only

--
Happy Coding!
Morten Wennevik [C# MVP]
Oct 3 '06 #4
Even with the /debug:pdbonly option ? I tried yestarday, it creates the PDB
file while I'm still considered in release mode but it doesn't seem to
actually use those PDB files when an exception occurs...

--
Patrice

"Morten Wennevik" <Mo************@hotmail.coma écrit dans le message de
news: op***************@tr024.bouvet.no...
On Tue, 03 Oct 2006 12:03:57 +0200, Hans Kesting
<ne***********@spamgourmet.comwrote:
>Is that available *always*? I thought linenumber-info was only available
when there is a .pdb file present for the dll where the error is? (Read:
when it has been compiled in DEBUG mode.)

Line number is available in DEBUG only

--
Happy Coding!
Morten Wennevik [C# MVP]

Oct 3 '06 #5
I tested this and you guys are right only in DEBUG does give line numbers.

So that I means I have deploy in DEBUG if i want to be able to debiug any
problems.

What is the performance hit in DEBUG mode, any ideas???

"Rotsey" <ma***********@RemoveThis.optusnet.com.auwrote in message
news:OA**************@TK2MSFTNGP02.phx.gbl...
Hi,

Am trying to be able to the line number of an exception.

The stack trace is not showing it.

rotsey

Oct 6 '06 #6
Hi Patrice,

Sorry for the lack of reply,

My tests conclude with line numbers for both /debug:full and
/debug:pdbonly, but the /debug[+|-] will override line numbers

csc /debug:full /debug- test.cs

Will not display line numbers, though nor will it create a pdb file

you may also try just

csc /debug+ test.cs

Which should display line numbers.

If you still get no line numbers, try to compile your code on another
system. If that works, I would reinstall .net framework.

On Tue, 03 Oct 2006 14:05:31 +0200, Patrice <sc****@chez.comwrote:
Even with the /debug:pdbonly option ? I tried yestarday, it creates the
PDB
file while I'm still considered in release mode but it doesn't seem to
actually use those PDB files when an exception occurs...


--
Happy Coding!
Morten Wennevik [C# MVP]
Oct 12 '06 #7

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

Similar topics

1
by: Adam | last post by:
I apologize if this is an easy question, but I can't find a way to do this. I want the line number of where an error occurred to be shown in a new exception's message when I use a try/catch...
1
by: Tony | last post by:
In certain applications I have (vb.net 2003), when I catch an exception and print the toString (or stacktrace), it does NOT show the line number. However, other simple apps I have it does show...
0
by: Me | last post by:
I am writing a web application and I want to catch and rethrow every unhandled exception to the Application_Error. However, the line number indicated in the stack trace is from the Throw line,...
3
by: Dan Holmes | last post by:
Server stack trace: at IVS.Framework.ControlNumberService.InstallComponent(Identity id, ControlNumberInfo ctrlNumber) in...
4
by: Jeff Jarrell | last post by:
I have a block of code that during development is prone to casting errors. It is mostly a DataReader type thing. It looks something like this. _prtPNID = myDLReader.GetString("prtPNID")...
0
by: Trak | last post by:
I had written coding to fetch line number of an exception. The line number is returned as 0 when the line number cannot be determined. This works fine with normal forms, where the correct line number...
2
by: Troels Thomsen | last post by:
Hello , When an exeption occurs in a IronPython executet script, and I print the sys.exc , i get something ugly like the example below. How can I get the fileName and line number? Thx in...
5
by: IdleBrain | last post by:
I am trying to log the Application name, Method name, line number and column number whenever an exception is generated in an C# 2005 application using the following code. Problem is that the...
2
by: =?Utf-8?B?QXJ0aHVyIFBhcmtlcg==?= | last post by:
I've been having a problem occasionally with exceptions having the wrong line number listed. The situation is this: I have a function with a try-catch, and in the catch it logs the message and...
1
by: sophie_newbie | last post by:
I'm sure this is exceedingly simple but I can't find it anywhere. When I catch an exception I would like to report the line number of the exception as well as the error info. try: someError()...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
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
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.