在调试模式下在 Visual Studio 2008 中编辑代码
我很想知道是否有一种方法可以在 C# VS 2008 遇到断点并且我正在遍历代码时编辑代码...我可以修改代码吗(例如变量中的值,或者如果我的单步执行行即将遇到 if 语句...我可以修改 if 语句...等)吗? 到目前为止,我必须停止运行VS,修改代码,然后按F5并等待再次命中断点。
当断点命中时,我正在遍历代码,并尝试编辑代码,我收到一条消息“当调试器已附加到正在调试的代码已在运行的进程并在构建时进行了优化时,不允许进行更改”或运行时间。”
I am curious to know if there is a way to edit code in C# VS 2008 right when it has hit a breakpoint and I am walking thru the code... can I modify the code (such as the value in a variable or if my stepthrough line is about to hit an if statement ... can I modify the if statement....etc)?
So far, I have to stop running VS, modify the code, then hit F5 and wait till the breakpoint is hit again.
When the breakpoint hits, and I am walking thru the code, and I attempt to edit the code, I get a message "Changes are not allowed when the debugger has been attached to an already running process of the code being debugged was optimized at build or run time."
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
我知道为什么在调试版本中禁用“编辑+继续”的原因只有几个。首先也是最重要的是 64 位操作系统,E+C 仅适用于 32 位代码。使用“项目 + 属性”、“构建”选项卡、“平台目标”= x86 修复该问题。
这也是一个可能已关闭的选项。工具 + 选项、调试、编辑并继续、启用复选框。
如果这没有帮助,请告诉我们更多有关您正在调试的代码类型、启动项目时选择的项目模板、如何让调试器中断以及从“调用堆栈”窗口复制的堆栈跟踪的信息。
There are only a few reasons I know of why Edit+Continue would be disabled in the Debug build. First and foremost is a 64-bit operating system, E+C only works for 32-bit code. Fix that with Project + Properties, Build tab, Platform Target = x86.
It is also an option that might have been turned off. Tools + Options, Debugging, Edit and Continue, Enable checkbox.
If this doesn't help, tell us a bit more about the kind of code you're debugging, the project template you selected when you started the project, how you got the debugger to break and a stack trace copied from the Call Stack window.
是的,你可以。
这称为编辑并继续 .
请注意,它有一些限制 。
编辑:您需要切换到调试版本。
Yes, you can.
This is called Edit and Continue.
Note that it has some limitations.
EDIT: You need to switch to a debug build.
要在中断模式下修改变量的值或设置属性,请转到“立即”窗口,设置新值,然后按回车键,例如
要检索值,您只需将其打印到窗口 ee
To modify the value of a variable or set a property while in break mode go to the Immediate window, set the new value, and hit return e.g.
To retrieve a value you can just print it to the window e.e.
针对这个问题的回答:
您不能直接将新值弹出到变量中,但您可以执行以下操作:
请参阅有关启用“编辑和编辑”功能的其他答案。继续 - 特别是确保您处于调试模式。
In response to this question:
You cannot pop a new value into a variable directly, but what you can do is this:
See the other answers about enabling Edit & Continue -- in particular, make sure you're in Debug mode.
为了解决这个问题,我做了以下操作...
BUILD >配置管理器
活动解决方案配置:调试
项目上下文配置:DEBUG
然后 TOOLS >选项>调试>编辑&继续
确保编辑&选择“继续”,
然后“构建”>“清洁解决方案
然后构建>重建解决方案
然后开始调试,然后暂停,然后您的代码应该是可编辑的
To solve this problem I did the following...
BUILD > CONFIGURATION MANAGER
Active solution configuration: DEBUG
project context configuration: DEBUG
then TOOLS > OPTIONS > DEBUGGING > EDIT & CONTINUE
make sure edit & continue is selected
then BUILD > CLEAN SOLUTION
then BUILD > REBUILD SOLUTION
Then start debug, then pause, then your code should be editable
以下答案对我有用:
http://whyiamright.wordpress.com/2007/12/20/aspnet-edit-and-continue-in-visual-studio-2005/
第二点说 - project-properties-web->启用编辑并继续。
就是这样。
Below answer worked for me :
http://whyiamright.wordpress.com/2007/12/20/aspnet-edit-and-continue-in-visual-studio-2005/
The second point says - project-properties-web-> enable edit and continue.
thats it.