简体   繁体   English

调试时的 Visual Studio 2015 断点偏移

[英]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.我遇到了 Visual Studio 2015 的异常行为,参考下面附加的图像,我试图在第 1438 行放置一个断点,但在我开始调试工作区后,断点转移到第 1440 行,这影响了我的代码调试过程。

Before Debugging调试前

After Debugging调试后

Hope someone could assist on this matter.希望有人可以在这件事上提供帮助。

Thank you.谢谢你。

Check your line endings - you probably have a mix of CRLF and LF and CR.检查你的行尾——你可能混合了 CRLF 和 LF 和 CR。 Visual studio debugger assumes that the line ending is the same throughout the code. Visual Studio 调试器假定行尾在整个代码中是相同的。 If it started as CRLF and the line in question just has LF, then the breakpoint will be in a different place.如果它以 CRLF 开头,而有问题的行只有 LF,那么断点将位于不同的位置。

Simple fix if you have Word.如果您有 Word,则简单修复。

  1. open word开放词
  2. Open the source file in visual studio在 Visual Studio 中打开源文件
  3. Ctrl A, Ctrl X - get all the source from VS Ctrl A, Ctrl X - 从 VS 获取所有源代码
  4. In Word, Ctrl V - pasted in Word.在 Word 中,Ctrl V - 粘贴在 Word 中。 This will correct all the line endings这将更正所有行尾
  5. In Word, Ctrl A, Ctrl X - get all the code from word在 Word 中,Ctrl A,Ctrl X - 从 word 中获取所有代码
  6. In Visual Studio, Ctrl V - pasted back in visual studio在 Visual Studio 中,Ctrl V - 粘贴回 Visual Studio
  7. Save the source and rebuild保存源并重建

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM