VS2015 debugger showing incorrect values?

EDIT: when I run this code in Visual Studio 2013, the debugger shows Utc , not Local . This is a bug in the Visual Studio 2015 debugger.

EDIT: they took the code and inserted a standalone console application, but could not play in any version of VS. Bummer.

Can someone explain to me how you can see what you see in this screenshot ?!

  • At line 298, endingTimePeriodStartDate overridden as a Date value, but is set to DateTimeKind.Utc .
  • On line 300, if endingTimePeriodStartDate is actually not DateTimeKind.Utc , an exception is thrown.
  • The debugger breakpoint on line 305 has been removed, which means that an exception on line 302 was not endingTimePeriodStartDate.Kind == DateTimeKind.Utc , which means endingTimePeriodStartDate.Kind == DateTimeKind.Utc
  • (I also did System.Diagnostic.Debug.WriteLine(endingTimePeriodStartDate.Kind) before line 305 and prints "Utc" in the "Exit" window).
  • When I look at endingTimePeriodStartDate in the Locals and Watch debugger windows, and when the mouse hovers over a variable, the Kind property shows DateTimeKind.Local

enter image description here

+6
source share
1 answer

Typically, the debugger displays incorrect line numbers and switches to the old code if it runs a different version of the dll (old version) than the version displayed by your code. It happens

  • when there is some kind of caching
  • when the previous working version was closed incorrectly or is still running in another process.
  • when Visual Studio does not point to the correct code

Usually, to fix this, you should:

(Start by trying to "clean up" and "rebuild")

  • Stop all running or debugged Visual Studio projects.
  • Close all Visual Studio solutions and windows so that Visual Studio does not start.
  • (If the next step does not do this trick, then next time restart the computer, and then proceed to the next step)
  • We open only the solution that needs to be launched. Click Clean Solution. Then "Restore the solution."

Check if this problem has been fixed.

  1. Manually delete bin folders: (if cleanup / rebuild did not work)

5.1 If you are afraid, back up the entire source directory. After everything works, delete the backup ...

5.2 manually go to the dependent projects (which are indicated in the project "wrong code") and in each of them go to obj and the bin folder and delete everything that was automatically created from there - in other words, everything that you did not put there manually . This is usually all. Don't worry, the visual studio will re-create the Debug and Release catalogs and populate them.

Remove obj and bin of your project.

Restore everything.

+2
source

All Articles