Wednesday, October 14, 2009

How To: Use 'Edit and Continue' Debugging Functionality in VS.NET 2008

In my early years of development, I worked a lot with VB6 and VBA in Access. One of the nice parts about developing on those platforms back then was the ability to make changes while debugging, and then continue debugging; hence 'Edit and Continue'. Dare I even say that Access was nice in that if a user had an error display on their screen I could even press [Ctrl] + [Break] at their computer and jump immediately into the code (assuming it was not compiled into a .mde). Ok, I know that is really bad, but back in the day when I was new to development, that made getting to the problem really direct and easy. Ow well, those were the days right?.... NOT! I love .NET!!

Visual Studio .NET has claimed for some time now to have 'Edit and Continue' capabilities. Several years ago, I jumped all over it for my ASP.NET development, but could never get it to actually work. To be honest I gave up on it, and assumed it did not work for ASP.NET development and was for mainly for Win Forms or other types of thick client development.

Well somewhere along the way it has become (or always has been and I didn't configure it properly) functional, and that will save me a lot of time. I can't count how many times I have been 5 levels deep into code and need to make a tiny change. I just got so used to pressing 'Stop' in VS.NET, making the changes, and then starting all over again. It didn't dawn on me to check out the 'Edit and Continue' functionality until something I read recently peaked my interest.

I know a lot of you may read this and say... "You didn't know about this???" Yes I did, but never obviously configured it properly or something else. So this post is more for the seasoned developers or new guys that may have let the 'Edit and Continue' functionality in ASP.NET projects go by the wayside because you could never get it to work either.

It is really simple to implement in VS.NET 2008, and really only involves (2) steps to get the functionality working. The only prerequisite is that you are using a 'Web Application' project type. The 'Website' project type in VS.NET does not have the 'Edit and Continue' functionality and will display a message like: "The source file has changed..." if you attempt to make changes while debugging, and will not allow changes.

If you are using a 'Web Application' project type here are the (2) steps you need to do to get the 'Edit and Continue' functionality to work in an ASP.NET app:

  1. In Tools -> Options -> Debugging -> Edit and Continue, make sure 'Enable Edit and Continue' is selected. In mine I left the default options selected and did not make any further changes.


  2. Double click on 'My Project' in 'Solution Explorer' (or alternatively, right click your project and select 'Properties'). From here select the 'Web' tab. Under 'Servers' make sure 'Use Development Server' is selected (not IIS), and finally, make sure to check the checkbox that states 'Enable Edit and Continue'.




After you have configured the above (2) steps, set a breakpoint on some code. I tried switching some string values and even variable names and then continue debugging, and everything worked!

Again, this post doesn't really highlight anything brand new in VS.NET, but is really just there to help dust something off that some of us may have forgotten about or overlooked.

2 comments:

  1. Thanks for this, I didn't activate "enable and continue" under the web project preferences and because of that it was not working. Thanks for showing me the way :)

    ReplyDelete
  2. I did all of these before-- still won't work until now. Somehow I think there's more to do with VB that EnC won't work as-is. This is why C# seems to be a winner.

    ReplyDelete