Ri Cerd Ng
Ri Cerd Ng

Reputation: 11

Visual Studio 2015 Breakpoint Offset When Debugging

I had faced an abnormal visual studio 2015 behavior, referring to the image attached below I was trying to place a breakpoint at line 1438, but right after I start debugging the workspace the breakpoint shifted to line 1440 instead which were affecting my code debugging process.

Before Debugging

After Debugging

Hope someone could assist on this matter.

Thank you.

Upvotes: 1

Views: 374

Answers (1)

cup
cup

Reputation: 8267

Check your line endings - you probably have a mix of CRLF and LF and CR. Visual studio debugger assumes that the line ending is the same throughout the code. If it started as CRLF and the line in question just has LF, then the breakpoint will be in a different place.

Simple fix if you have Word.

  1. open word
  2. Open the source file in visual studio
  3. Ctrl A, Ctrl X - get all the source from VS
  4. In Word, Ctrl V - pasted in Word. This will correct all the line endings
  5. In Word, Ctrl A, Ctrl X - get all the code from word
  6. In Visual Studio, Ctrl V - pasted back in visual studio
  7. Save the source and rebuild

Upvotes: 2

Related Questions