I am building an ASP.NET application with Visual Studio 2013 Premium for the .NET framework version 4.5, using IIS Express in the debugging process. Now I have run into a problem that happened with other projects before (very very rarely), but is extremely frequently occurring in this one:
Changes in my code often are not compiled correctly and thus an older version of the program is started in IIS. I first noticed this when I got a
NullReferenceException in one line of code, then added a check for
null around it and then got the same error again, just now in the line where the check happened (which is the line number where the exception occurred before). Another symptom is that no breakpoints are hit anymore because of missing symbols (due to the discrepancy in the version of the code I think).
Now I have read all kinds of threads here and on MSDN regarding this issue, and it seems like many people have this from time to time and noone has a solution that works for everyone.
Doing a clean/rebuild does not work at all when I encounter this problem, but usually deleting the bin and obj folders did the trick. But what happens now is the following:
After starting the debugging process (
F5), I can see that my breakpoints aren't hit, so I stop it, delete the bin/obj folders and Rebuild All. This does not work and always fails with many errors saying that a namespace could not be found (even though IntelliSense proposes it there and it does in fact exist) and the assembly (which would provide the namespace) was missing (and it indeed is in the final output folder of the startup project; but it got created in its own project bin folder...). Then I Rebuild All a second time and it will magically work. The next start of the program does everything as I wish it to be. But after that, I am at the point where already the 2nd or 3rd restart produces the problem again (no breakpoints, old code) and I can start over with deleting the folders. I have to add that this behaviour started last week and got ever more frequent since. It wasn't always at the point where I had to delete the folders after every 2nd try.
All this is of course unbearable as it's impossible to work under these circumstances. But I am at a loss as to what to do. I have worked (among others) through this MSDN thread and this SO question, but nothing seems to work for me.
Do you have any other suggestions? Could there be something wrong at some point that produces this kind of behavior explicitly? Especially the part where the first rebuild doesn't but the 2nd does indeed work puzzles me and feels like there could be something I'm doing wrong.
Edit: I tested another scenario right now: After the first rebuild I get the above errors about the missing assembly. Then I really remove the reference to that assembly and despite that, the 2nd rebuild still goes through without errors now! How can that be?