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

Get the line number where the exception occoured

Is there any property in Exception to get the line number where the error has occurred ? I do not want the line number by using StackTrace.

Regards
Raghul
Dec 12 '08 #1
2 6634
kenobewan
4,871 Expert 4TB
@raghulvarma
Not sure what you have against stacktrace, works well for me. You may find this article interesting:

Rich Custom Error Handling with ASP.NET
Dec 12 '08 #2
PRR
750 Expert 512MB
@raghulvarma
If you are looking for exact line number you can do so using StackTrace
Expand|Select|Wrap|Line Numbers
  1. catch(Exception ex)
  2. {
  3. StackTrace st = new StackTrace(ex,true);
  4.  
  5.                 StackFrame sf = st.GetFrame(0);              
  6.  
  7.                 Console.WriteLine( sf.GetMethod().ToString());
  8.                 Console.WriteLine(sf.GetFileLineNumber().ToString());
  9. }
  10.  
StackTrace
Constructor
Dec 12 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

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: 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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.