调试时编辑 C#
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/447706/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Editing C# while debugging
提问by
I know I've dealt with this issue before, but the settings to override this always seem to be changing.
我知道我以前处理过这个问题,但是覆盖它的设置似乎总是在改变。
I have a C# project in Visual Studio 2008. While I'm debugging, VS won't let me edit my code. I don't want to Edit and Continue - I just want to make changes for my next build. Edit and Continue is disabled. When I try to edit a file while debugging my project, I get a little message that the files are now Read-Only.
我在 Visual Studio 2008 中有一个 C# 项目。在调试时,VS 不允许我编辑代码。我不想编辑并继续 - 我只想为我的下一个版本进行更改。编辑并继续被禁用。当我在调试项目时尝试编辑文件时,我收到一条小消息,指出文件现在是只读的。
Anyone dealt with this recently in VS2K8?
有人最近在 VS2K8 中处理过这个问题吗?
回答by Jeff Martin
I am not sure why Edit and Continue won't work for you. If you are debugging and attached to the process you are debugging in, your pages should be locked or the debugger can't show you what is actively running.
我不确定为什么“编辑并继续”对您不起作用。如果您正在调试并附加到您正在调试的进程,您的页面应该被锁定,否则调试器无法向您显示正在运行的内容。
Here is a reference to Edit and Continue. http://whyiamright.wordpress.com/2007/12/20/aspnet-edit-and-continue-in-visual-studio-2005/
这是对“编辑并继续”的引用。 http://whyiamright.wordpress.com/2007/12/20/aspnet-edit-and-continue-in-visual-studio-2005/
If you are programming for the next build, it doesn't make sense to me to be trying to debug your current build.
如果您正在为下一个版本进行编程,那么尝试调试您当前的版本对我来说没有意义。
回答by Welbog
The last time I had this problem I fixed it by changing the following settings:
Project properties -> Compile -> Advanced Compile Options -> Set "Generate debug info" to Fulland uncheck "Enable optimizations".
Worked for me. Don't know about you, though.
上次我遇到这个问题时,我通过更改以下设置来修复它:
项目属性 -> 编译 -> 高级编译选项 -> 将“生成调试信息”设置为完整并取消选中“启用优化”。
为我工作。不知道你,虽然。
回答by Luke
I just tried this in VS2k8. All I had to do was enable Edit and Continue in Tools > Options > Debugging menu.
我刚刚在 VS2k8 中尝试过这个。我所要做的就是在“工具”>“选项”>“调试”菜单中启用“编辑并继续”。
You won't be able to use E&C when you have projects set to release mode
当您将项目设置为发布模式时,您将无法使用 E&C
回答by Hans Passant
Tools + Options, Debugging + Edit and Continue. Turn off the Enable checkbox. You can now edit the source code. You will get a warning when you continue to debug after you've made a change.
工具 + 选项,调试 + 编辑并继续。关闭启用复选框。您现在可以编辑源代码。在进行更改后继续调试时,您将收到警告。
回答by Hans Passant
Thanks everyone for your input, even the comments that directly contradict each other. I had tried enabling and disabling Edit-and-Continue a handful of times to no effect. However, I just restarted VS and now my enabling/disabling E&C is affecting my ability to edit during debugging just the way I would have expected. I guess it was just a bug in VS...
感谢大家的投入,即使是直接相互矛盾的评论。我曾多次尝试启用和禁用“编辑并继续”,但没有任何效果。但是,我刚刚重新启动了 VS,现在我的启用/禁用 E&C 正在以我预期的方式影响我在调试期间进行编辑的能力。我想这只是VS中的一个错误......
Thanks again.
再次感谢。
回答by sys_debug
In VS 2010, go to Debug->Options->tick Enable Address Level Debugging :) reverse for reverse operation :)
在 VS 2010 中,转到 Debug->Options->tick Enable Address Level Debugging :) reverse 进行反向操作 :)