Link to home
Start Free TrialLog in
Avatar of Ionican
Ionican

asked on

Exception Line Numbers Riddle

I am attempting to debug a vb.net/ASP.NET application in VS2010.

When hitting F5 I get an exception on a seemingly innocuous line of code.  After playing around I've worked out that the exception is actually being thrown 5 lines before (and indeed looking at the stack trace this is confirmed).

Obviously this makes debugging pretty tricky - am I missing something obvious? I've tried to 'snip' all the evidence below!

 User generated image
Avatar of Bardobrave
Bardobrave
Flag of Spain image

Well... I think here your problem is pretty clear, you're using "field" array on your code without assigning it any value, this provokes the raise of the exception.

The reason why the exception is being misplaced is a mistery to me... maybe a bug on VS debugger?
Avatar of shadow77
shadow77

Your field array is null when you try to store elements within it.

You need to add
    field = New String(ArgCount - 1) {}
after line 416.

Line 425 is the first line with executable code after line 420, which may be why your exception occurs there.
Avatar of Ionican

ASKER

Yes thanks Bardo - I spotted that one eventually (coffee helped).

But the odd 'offset' does worry me (and I've had this issue before) - makes me question the integrity of my dev environment (and the subsequent copying over to the staging server).

Has anyone else seen this before?
ASKER CERTIFIED SOLUTION
Avatar of Avodah
Avodah
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
BTW Select the THROWN checkboxes.

DaTribe
Avatar of Ionican

ASKER

Thanks DaTribe - that fixed it!  Not so lovely optimisations!
If my suggestion fixed it them  how come I don't get the points.

DaTribe
Avatar of Ionican

ASKER

Hi,

Bit confused here (apologies I'm an EE newbie) - but here goes:  

I played with the optimisations settings and tried to recreate my original issue (the issue being that the debugger was flagging up the exception in the wrong line) and it seemed that the optimisations flag did indeed correct the problem.  I was not able to roll back my code to recreate the exact original problem but it seems highly likely that DaTribe's contribution enabled me to eliminate the unpredictable debugger behaviour I was observing and which was the subject of this question.

To be clear: the question was not with the buggy code - that's reasonably straightforward (but thanks anyway to Shadow and Bardo) - it was that the debugger was sending me elsewhere to resolve the issue, hence the title of the question.

Hope that helps - Many thanks

Yes this was my understanding of the entire scenario, however the question still remains - why not close the question and award no points instead of accepting my solution and awarding full points?

DaTribe
Avatar of Ionican

ASKER

Yes this makes sense as the appropriate outcome.

Thank you
I am restarting the auto-close procedure on behalf of the question asker. After Moderator review, the new disposition seems to be more appropriate to the outcome of this question.

- thermoduric -
EE Community Support Moderator
https://www.experts-exchange.com/questions/26631209/28-Nov-10-12-Automated-Request-for-Attention-Q-26630476.html