Editing C# while debugging

2020-05-25 07:20发布

问题:

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.

Anyone dealt with this recently in VS2K8?

回答1:

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.



回答2:

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/

If you are programming for the next build, it doesn't make sense to me to be trying to debug your current build.



回答3:

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 Full and uncheck "Enable optimizations".

Worked for me. Don't know about you, though.



回答4:

I just tried this in VS2k8. All I had to do was enable Edit and Continue in Tools > Options > Debugging menu.

You won't be able to use E&C when you have projects set to release mode



回答5:

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...

Thanks again.



回答6:

In VS 2010, go to Debug->Options->tick Enable Address Level Debugging :) reverse for reverse operation :)