Is there an option to edit the code when debugging in a breakpoint in Visual Studio. When I stop, all files seems locked for editing.
在Visual Studio中的断点中进行调试时是否有编辑代码的选项。当我停止时,所有文件似乎都被锁定以进行编辑。
Is there a way to change this behaviour? It is possible in Eclipse
有没有办法改变这种行为?它可以在Eclipse中实现
EDIT: after trying all suggested below (including move it to debug from release) now it is telling me I don't have the correct ms-office version and debug cannot start in debug mode. However, in release mode it was working. I am trying to debug an outlook add-in.
编辑:尝试下面的所有建议(包括将其从发布调试),现在它告诉我,我没有正确的ms-office版本,调试无法在调试模式下启动。但是,在发布模式下,它正在运行。我正在尝试调试outlook加载项。
5 个解决方案
#1
34
Yes, it's called "Edit and Continue", in Tools | Options under Debugging. Note that it's not compatible with IntelliTrace, so you have to disable that if you're using it. (Thank you Anton Semenov for that info.)
是的,在工具|中称为“编辑并继续”调试下的选项。请注意,它与IntelliTrace不兼容,因此如果您正在使用它,则必须禁用它。 (感谢Anton Semenov提供的信息。)
Edit: If you're using a really old version (the original VS.Net, as opposed to VS.Net 2005 or later), it was pretty fiddly about this (or didn't have it, I can't quite recall; I just remember being frustrated). But if you're using VS.Net 2005 or later, in my experience, it's enabled by default and works very well. When execution is paused (and you said you'd hit a breakpoint, so...), you can make quite a variety of changes and the environment will happily compile them and continue. Make sure all of the projects you want to debug are in the solution.
编辑:如果你使用的是一个非常古老的版本(最初的VS.Net,而不是VS.Net 2005或更高版本),它对此非常繁琐(或者没有它,我不记得了;我只记得感到沮丧。但是如果您使用VS.Net 2005或更高版本,根据我的经验,它默认启用并且运行良好。当执行暂停时(你说你打了一个断点,所以...),你可以进行各种各样的改变,环境会愉快地编译它们并继续。确保要调试的所有项目都在解决方案中。
#2
5
In general, it is possible, but you have to make sure you are compiling your project to x86
platform.
通常,这是可能的,但您必须确保将项目编译为x86平台。
For this, right click on the project name in the Solution Explorer, go to Build and set the Platform Target to x86
.
为此,在解决方案资源管理器中右键单击项目名称,转到Build并将Platform Target设置为x86。
Edit:
Of course, in order to be able to edit a file, the execution need to be paused (in a breakpoint, for example)
编辑:当然,为了能够编辑文件,需要暂停执行(例如,在断点中)
#3
4
yes you can update code in debug mode. Set the break point to the point which u want to edit . When the execution comes to this point then edit your code then press f5. It will take the changes.
是的,您可以在调试模式下更新代码。将断点设置为您要编辑的点。执行到此时,然后编辑代码,然后按f5。它会采取变化。
#4
0
win7
Yes, it's called "Edit and Continue", in Tools | Options under Debugging. Note that it's not compatible with IntelliTrace
是的,在工具|中称为“编辑并继续”调试下的选项。请注意,它与IntelliTrace不兼容
win10 can turn on IntelliTrace
win10可以打开IntelliTrace
#5
-1
# How to set a Visual Studio breakpoint to pause execution of your program at that point
#如何设置Visual Studio断点以暂停程序的执行
To set a breakpoint, first decide which executable line of code you want the program to stop on 'Before' that line of code is executed.
要设置断点,首先要确定您希望程序在执行该代码行之前的“之前”停止哪些可执行代码行。
Set the cursor flashing anywhere on that line.
将光标设置为闪烁在该行的任何位置。
Press [F9] to set the breakpoint, and a red circle appears on the far left.
按[F9]设置断点,最左侧出现红色圆圈。
Press [F5] to run program.
按[F5]运行程序。
To close the program, click on the program window so that it is your active window, and press [Ctrl]+[Pause].
要关闭程序,请单击程序窗口以使其成为活动窗口,然后按[Ctrl] + [Pause]。
To disable the breakpoint, but not delete it, set your cursor flashing on that line again, and press [Ctrl]+[F9], which turns the circle white. (Or Right-click the red circle, and click "Disable Breakpoint")
要禁用断点但不删除断点,请将光标再次设置在该行上,然后按[Ctrl] + [F9],将圆圈变为白色。 (或者右键单击红色圆圈,然后单击“禁用断点”)
To delete the breakpoint, Right-click the red circle, and click "Delete Breakpoint".
要删除断点,请右键单击红色圆圈,然后单击“删除断点”。
Using the mouse as an alternative way to set, disable, or delete breakpoints
使用鼠标作为设置,禁用或删除断点的替代方法
Once you know where the breakpoints show up on the left side of the Visual Studio window, you can set a breakpoint by double-clicking at the point where you want the breakpoint to be placed, and it will be placed there.
一旦知道断点显示在Visual Studio窗口左侧的哪个位置,就可以通过双击要放置断点的位置来设置断点,并将其放置在那里。
If you double-click a red breakpoint, it will be removed.
如果双击红色断点,则会将其删除。
If you hover your mouse pointer on a breakpoint, two little icons appear slightly above, and to the right of the breakpoint.
如果将鼠标指针悬停在断点上,则会在断点的右上方略微出现两个小图标。
Clicking that right-side icon toggles the breakpoint from active to disabled, and vice-versa.
单击该右侧图标可将断点从活动切换为禁用,反之亦然。
For many more details, see the topic:
有关更多详细信息,请参阅主题:
"Getting Started with the Debugger"
“调试器入门”
https://msdn.microsoft.com/en-us/library/mt243867.aspx
Also, see the left column on the page from the link above for the additional pages:
另外,请参阅上面链接中页面左侧的其他页面:
"Navigating through Code with the Debugger"
“使用调试器浏览代码”
https://msdn.microsoft.com/en-us/library/y740d9d3.aspx
"Using Breakpoints"
https://msdn.microsoft.com/en-us/library/5557y8b4.aspx
Video: And for a 5-minute introductory video, see:
视频:有关5分钟的介绍性视频,请参阅:
"Debugging in VS Code"
“在VS代码中调试”
#1
34
Yes, it's called "Edit and Continue", in Tools | Options under Debugging. Note that it's not compatible with IntelliTrace, so you have to disable that if you're using it. (Thank you Anton Semenov for that info.)
是的,在工具|中称为“编辑并继续”调试下的选项。请注意,它与IntelliTrace不兼容,因此如果您正在使用它,则必须禁用它。 (感谢Anton Semenov提供的信息。)
Edit: If you're using a really old version (the original VS.Net, as opposed to VS.Net 2005 or later), it was pretty fiddly about this (or didn't have it, I can't quite recall; I just remember being frustrated). But if you're using VS.Net 2005 or later, in my experience, it's enabled by default and works very well. When execution is paused (and you said you'd hit a breakpoint, so...), you can make quite a variety of changes and the environment will happily compile them and continue. Make sure all of the projects you want to debug are in the solution.
编辑:如果你使用的是一个非常古老的版本(最初的VS.Net,而不是VS.Net 2005或更高版本),它对此非常繁琐(或者没有它,我不记得了;我只记得感到沮丧。但是如果您使用VS.Net 2005或更高版本,根据我的经验,它默认启用并且运行良好。当执行暂停时(你说你打了一个断点,所以...),你可以进行各种各样的改变,环境会愉快地编译它们并继续。确保要调试的所有项目都在解决方案中。
#2
5
In general, it is possible, but you have to make sure you are compiling your project to x86
platform.
通常,这是可能的,但您必须确保将项目编译为x86平台。
For this, right click on the project name in the Solution Explorer, go to Build and set the Platform Target to x86
.
为此,在解决方案资源管理器中右键单击项目名称,转到Build并将Platform Target设置为x86。
Edit:
Of course, in order to be able to edit a file, the execution need to be paused (in a breakpoint, for example)
编辑:当然,为了能够编辑文件,需要暂停执行(例如,在断点中)
#3
4
yes you can update code in debug mode. Set the break point to the point which u want to edit . When the execution comes to this point then edit your code then press f5. It will take the changes.
是的,您可以在调试模式下更新代码。将断点设置为您要编辑的点。执行到此时,然后编辑代码,然后按f5。它会采取变化。
#4
0
win7
Yes, it's called "Edit and Continue", in Tools | Options under Debugging. Note that it's not compatible with IntelliTrace
是的,在工具|中称为“编辑并继续”调试下的选项。请注意,它与IntelliTrace不兼容
win10 can turn on IntelliTrace
win10可以打开IntelliTrace
#5
-1
# How to set a Visual Studio breakpoint to pause execution of your program at that point
#如何设置Visual Studio断点以暂停程序的执行
To set a breakpoint, first decide which executable line of code you want the program to stop on 'Before' that line of code is executed.
要设置断点,首先要确定您希望程序在执行该代码行之前的“之前”停止哪些可执行代码行。
Set the cursor flashing anywhere on that line.
将光标设置为闪烁在该行的任何位置。
Press [F9] to set the breakpoint, and a red circle appears on the far left.
按[F9]设置断点,最左侧出现红色圆圈。
Press [F5] to run program.
按[F5]运行程序。
To close the program, click on the program window so that it is your active window, and press [Ctrl]+[Pause].
要关闭程序,请单击程序窗口以使其成为活动窗口,然后按[Ctrl] + [Pause]。
To disable the breakpoint, but not delete it, set your cursor flashing on that line again, and press [Ctrl]+[F9], which turns the circle white. (Or Right-click the red circle, and click "Disable Breakpoint")
要禁用断点但不删除断点,请将光标再次设置在该行上,然后按[Ctrl] + [F9],将圆圈变为白色。 (或者右键单击红色圆圈,然后单击“禁用断点”)
To delete the breakpoint, Right-click the red circle, and click "Delete Breakpoint".
要删除断点,请右键单击红色圆圈,然后单击“删除断点”。
Using the mouse as an alternative way to set, disable, or delete breakpoints
使用鼠标作为设置,禁用或删除断点的替代方法
Once you know where the breakpoints show up on the left side of the Visual Studio window, you can set a breakpoint by double-clicking at the point where you want the breakpoint to be placed, and it will be placed there.
一旦知道断点显示在Visual Studio窗口左侧的哪个位置,就可以通过双击要放置断点的位置来设置断点,并将其放置在那里。
If you double-click a red breakpoint, it will be removed.
如果双击红色断点,则会将其删除。
If you hover your mouse pointer on a breakpoint, two little icons appear slightly above, and to the right of the breakpoint.
如果将鼠标指针悬停在断点上,则会在断点的右上方略微出现两个小图标。
Clicking that right-side icon toggles the breakpoint from active to disabled, and vice-versa.
单击该右侧图标可将断点从活动切换为禁用,反之亦然。
For many more details, see the topic:
有关更多详细信息,请参阅主题:
"Getting Started with the Debugger"
“调试器入门”
https://msdn.microsoft.com/en-us/library/mt243867.aspx
Also, see the left column on the page from the link above for the additional pages:
另外,请参阅上面链接中页面左侧的其他页面:
"Navigating through Code with the Debugger"
“使用调试器浏览代码”
https://msdn.microsoft.com/en-us/library/y740d9d3.aspx
"Using Breakpoints"
https://msdn.microsoft.com/en-us/library/5557y8b4.aspx
Video: And for a 5-minute introductory video, see:
视频:有关5分钟的介绍性视频,请参阅:
"Debugging in VS Code"
“在VS代码中调试”