Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Visual studio referencing the wrong row during exceptions?

Some simple rows of code below:

string[] countries = new string[1];
string[] cities = new string[1];

countries[0] = "USA";
countries[1] = "England";
cities[0] = "Chicago";  

When Visual Studio throws the null exception it references the following row and not the row where the exception occurred:
enter image description here

I know the line number is correct when you view details of the problem. However, I often spend more time than necessary searching the wrong variables because the visual representation of the exception was wrong.

Is it possible to tweak VS or do something else to solve this issue? Is it a known problem or is it just me?

like image 363
Niklas Avatar asked Aug 11 '11 15:08

Niklas


People also ask

How do I fix unhandled exception in Visual Studio?

To change this setting for a particular exception, select the exception, right-click to show the shortcut menu, and select Continue When Unhandled in User Code. You may also change the setting for an entire category of exceptions, such as the entire Common Language Runtime exceptions).

What does Exception thrown mean Visual Studio?

In Visual Studio, when exceptions are thrown or end up unhandled, the debugger can help you debug these by breaking just like it breaks when a breakpoint is hit. In this blog post we will look at the different classifications of exceptions and how to configure when the debugger will break for those exceptions.


1 Answers

This is apparently a known bug.

like image 186
CodeNaked Avatar answered Sep 17 '22 03:09

CodeNaked