0

I am getting the following exception from my app: enter image description here

The line #1681 in the exception is pointing to this line in my app's code: enter image description here

Where iSC_Queue is a simple DTO class like this:

public class iSC_Queue
{
    public string ID                  { get; set; }
    public string TriggerTableName    { get; set; }
    public string TriggerTableID      { get; set; }
    public string TriggerTableIDValue { get; set; }
}

How is this possible? I am pretty sure, List initialisation doesn't produce this index out of bounds error. It must be happening somewhere inside my "Parse Queue Entries" code block.

How can I get C# exception to show the real line/stack trace where the error is?

8
  • 2
    it's a lame excuse for actually solving the underlying problem, but if I were in your shoes, I'd add a bunch of debug output to see which parts of the code are actually executed Commented Jul 10, 2013 at 9:06
  • 1
    CTRL D, C will bring up the call stack (Or Debug -> Windows -> Call stack) Commented Jul 10, 2013 at 9:07
  • 1
    And, I know it is not list init. That function is not wrapped in an try catch Commented Jul 10, 2013 at 9:07
  • And what about a debug session, where you walk your code step by step??? Commented Jul 10, 2013 at 9:09
  • 7
    It suggests that the source code has been edited since the compiled code that's generating that error message. Commented Jul 10, 2013 at 9:09

5 Answers 5

2

It looks like it's not the line you are on, you may have be erroring on a different line.

You are seeing a message box so it must be in one of your try catch sections.

If you are parsing strings in the next section, quite likely you are attempting to split the string into a few pieces and you are not getting the number of sub strings you are expecting.

If you show more code we can help more?

Sign up to request clarification or add additional context in comments.

1 Comment

yea, I have like a global try catch as well as internal ones. I've narrowed it down to the first region of code (where parse) work is done: pastebin.com/1vaNSV7k
0

try this

[Serializable()]
 public class iSC_Queue
 {
     public string ID { get; set; }
     public string TriggerTableName { get; set; }
     public string TriggerTableID { get; set; }
     public string TriggerTableIDValue { get; set; }
 }

1 Comment

sadly, the issue isn't exactly with the DTO, rather than parsing code (somewhere in here, pastebin.com/1vaNSV7k)
0

Are you absolutely sure the screenshot of the message box is from the current version of your application (even if you did as little as remove or add empty lines to your code to make it more readable)?

It's quite possible for VS to run an older binary if there were compilation errors, and then the line numbers can be switched around. Otherwise, it shouldn't be possible for the application to point to that line.

1 Comment

yes, this is the current version. I have a global exception catcher as well as internal code block ones. Perhaps the global one got triggered, instead of the internal ones?
0

The line number given in the exception message doesn't come from your application's .exe or .dll file; it comes from a .pdb file. If there isn't a .pdb file present, you don't get a line number at all, but just a byte offset from the start of the method.

If the line numbers you're getting don't seem to correspond to your source code, then either [a] the line number is correct but you're looking at the wrong version of the source code, or [b] the line number is incorrect because your application files and the .pdb file are out of sync (perhaps last time a new version was installed to the server, a new .pdb file wasn't installed, so the old one's still present).

Comments

0

Not an answer, per se - but a rebuttal to some of those I've read. I stumbled upon this, while trying to figure out why I get the same error with:

List<string> strTemp = new List<string>();

(edited for html rendering - missed the <string> tags) ON OCCASSION

at least, that's the line pointed to. I add the "on occasion" because it doesn't always happen. More often than not (barely, it's close), the code works as expected. Occasionally, however (for a few days at a time - weeks?) it will continually throw the above. Then, after a while, it stops. For the record, .pdb and .dll for web service deployed and dated identically, so no chance of a code mismatch.

Also note: this is the 4th version of the particular code I've launched (hidden feature until I get it right). In all 4 versions, the error would occasionally appear, and with all 4 versions, the error pointed to the above line (4 different line numbers, due to changes)

I've been leaning to windows/chrome updates causing the issue to come and go, but that's only a wild guess, because I've yet to find a better answer.

2 Comments

Minor note: now 5 different deployments, 5 different line numbers - still pointing to the declaration above :(
and now the phantom error has moved to the first initialization in the function. at first - bool bReturn = false; was returning the " Object reference not set to an instance of an object." error, and when I split that up, moving the assignment below the declaration block, the following line - int i = 0; starting raising it... sigh this is a rough one

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.