Edit and Continue in Visual Studio 2005: joys and problems

So I happen to love edit & continue in C# with Visual Studio 2005. There are people who say it encourages sloppy programming (which is true), but for me, there are some things I just can’t code as effectively unless I know the runtime state. For example, writing complicated regular expressions against the results of various database queries and algorithms. Do I know if the regular expressions will work exactly before I run the code? No. Do I know if the code will work for all data permutations, beforehand? No.

Hence, edit & continue’s blessing. Fire away, hit your asserts or whatnot, and if things look wrong, adjust on the fly. Now, I don’t suggest doing big code restructuring while in edit & continue (could get messy & hard to manage), but you are able to if you need to.

Anyhow, much to my dismay I noticed that Edit & Continue stopped working after a while. I couldn’t figure out what the deal was, since I was always getting “Changes are not allowed when the debugger has been attached to an already running process or the code being debugged is optimized” whenever I tried to edit the code while debugging. I also noticed that not all my variables were showing up in the Locals & Auto debug windows (this is a hint for the punch line).

Michael Freidgeim has a nice workaround if you get stuck and my simple solution doesn’t help you.

His post didn’t help, and it took me a few minutes to realize that my project was in “Release” mode instead of “Debug.” Whooooops! I guess I didn’t notice that because I was able to mostly debug, even in release mode. But I shoulda caught that. Anyhow, flipping back to Debug mode fixed the issue.

0