Why can't I add code to a C# project in Visual Studio 2008

I have an intermittent problem with visual studio 2008.  I will work on a project for a period of time (not sure if length of time matters) but sometimes I will add code to a project and that code doesn't get incorporated into the project, it's there, it's saved, but it doesn't affect the behavior of the code.  

For example, today I have a project that is working, but I wanted to add a simple switch statement.  I added it, but the changes didn't appear in my results when I run the code in debug.  So I added a writeline statement inside the switch and still nothing.  I have encountered this behavior before and I have had to create a new project and paste the old code into it, at which time the changes are recognized.

Has anyone else encountered this?  Any idea how to fix?
Who is Participating?
crisco96Connect With a Mentor Commented:
I've never seen anything like this happen. Next time it happens try deleting your bin folder and rebuild and see if that fixes it. It almost seems like VS doesn't recompile the executable sometimes. Also double check that you don't have any compile errors when this happens.
rickmattAuthor Commented:
Also, I noticed that the new code is recognized if I switch from debug to release, but when I switch back to debug, the code is still there in the .cs file, but it doesn't get included in the run.
Carl TawnSystems and Integration DeveloperCommented:
You don't have any #if DEBUG blocks in there do you?
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

can you post your page first lines , that sounds kinda odd, have you rebuild the solution and right click into the code file to manually add???
Under the build menu, select rebuild solution then run it.  

rickmattAuthor Commented:
Awesome, that worked.  I never considered deleting the bin/Debug directory before, and it's a tiny bit of a hassle, but much better than rebuilding the entire project as I had done before.

Thanks for the quick solution!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.