473,657 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Exception error message has wrong line number

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
stack trace from the exception. The code generates an index-out-of-bounds
exception. When I look at the line number listed in the stack trace, it is
the first line of code in the function, which has nothing to do with array
indexes. One time this happened, I had to add a debug variable that kept
track of which section of code was executing and add that to the error
message.
I've had this happen several times with different code, and different
functions, but always an index-out-of-bounds, and always pointing to the
first line of the code inside the try block.
Does anyone have an explanation for this odd behavior?
Dec 27 '07 #1
2 3194
This is just a guess, but it is possible that you may have changed your code
but the .pdb file was not rebuilt. Try using "Rebuild" instead of "Build"
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"Arthur Parker" wrote:
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
stack trace from the exception. The code generates an index-out-of-bounds
exception. When I look at the line number listed in the stack trace, it is
the first line of code in the function, which has nothing to do with array
indexes. One time this happened, I had to add a debug variable that kept
track of which section of code was executing and add that to the error
message.
I've had this happen several times with different code, and different
functions, but always an index-out-of-bounds, and always pointing to the
first line of the code inside the try block.
Does anyone have an explanation for this odd behavior?
Dec 27 '07 #2
That's possible, although I went through several changes and re-compilations,
so the pdb file should have been updated during the process. The especially
odd part is that I haven't noticed this behavior with any other kind of
exceptions.

"Peter Bromberg [C# MVP]" wrote:
This is just a guess, but it is possible that you may have changed your code
but the .pdb file was not rebuilt. Try using "Rebuild" instead of "Build"
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
Dec 27 '07 #3

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

Similar topics

0
277
by: Fiona McBride | last post by:
Hi all, I have a really odd problem with some Visual Basic .NET 2003 code; I have a program that creates a number of windows which contain RichTextBox, Timers (disabled) and menus. The code runs fine and creates the windows as required, BUT if the program is left to do nothing for several hours, when it is brought back into focus it generates an exception error (Object reference not set to instance of an object - this always coincides...
4
2791
by: Seamus M | last post by:
It seems when I use the getLine() method of the Exception class, it returns the line number of the "throw new Exception" statement and not the line number where the error actually occured in the source file. Am I doing something wrong? - Seamus
1
2145
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 statement. Is there a way to get the line number where error occurred when catching an Exception? Example: try
6
6100
by: Tony | last post by:
Dear All, When I run an example program on the http://www.dotnetjunkies.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/data/datagrid1.src&file=VB\datagrid1.aspx&font=3 I received an error message: "The ConnectionString property has not been initialized.
1
2844
by: Ramanfromoz | last post by:
Hi, Developing a new we application. Everything okay on my local WIN XP PROFESSIONAL, IIS 5.0 running locally. The website is running smoothly. Now, the same code I am copying over to a WINDOWS 2003 SERVER, I created a new website, allocated port number 6000. Created a release version on my local machine and copied the WEB project from my local to http://ACTYD003:6000
4
2245
by: Craig831 | last post by:
First off, I apologize if this gets long. I'm simply trying to give you all enough information to help me out. I'm writing (almost finished, actually), my first VB.Net application. It's a forms application that is going to be used to extract data from a legacy system (VSAM based mainframe file structure), and output data in pipe-delimited record layouts, multiple record types per file, one file per chosen client. I have been working on...
6
4048
by: Steve Long | last post by:
Help, I'm running VS.NET 2003 and when I try to start my application, I get the "unhandled exception" dialog instead of the IDE highlighting the offending line of code. The problem appears to be instantiating a particular class in my project but the dialog doesn't tell me what code in the class is causing the problem (and it a large class). How can I get the IDE to take me to the offending line of code? If I put this line in my...
2
1590
by: John | last post by:
Hi there, I'm fairly new to VB.Net (and VB generally) so please bear with me if these are stupid questions! I'm trying run a procedure on multiple Visio files from a form created in VS 2003. This has worked fine when run from a click event on a single form at the start. It selected the items in a listbox (lstWorkFiles) and then went through each one. Now however, I moved the code to a second form (fmOps), which has some check...
9
2454
by: Frawls | last post by:
Hi I Am am having problems with a stored Procedure that i wrote. Basically whats happening is that the Stored procedure Runs fine when i EXECUTE it in SQL Query analyzer. But when i debug through the application in Visual Studio .NET 2003 the application an exception when it executes the query.
0
8823
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8603
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7320
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1944
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.