none
Visual Studio 2012 debug runs old code

    Question

  • Hi all,

    Thank you for any help you might be able to provide. I apologize, if this question sounds like it might have already been asked since I have found some similar titled questions but none of those solutions helped to resolve my problem, so I am posting a question of my own.

    I have Visual Studion 2012 Professional currently with Update 1. Its running on a Windows 7 64bit pc with SP1. I am also running a local version of IIS and my version of Internet Explorer is 9. No new windows updates have been installed. I am a local admin of the pc.

    The project that I am working on has begun to behave erradically when it comes to debugging. Most notably, when I go to debug ( F5 ) I am not getting the latest code changes incorporated into the debug process and its adding debug points into the code that I did not put there. What is making this more frustrating is just when I think I might have found a solution (e.g. something I've tried works once) then the problem starts again. Some of the things I have tried include:

    Restarting my computer
    Restarting Visual Studio
    Repairing Visual Studio
    Installing Update 1 to Visual Studio
    Deleting contents of Temporary ASP.NET folder
    Deleting contents of WebsiteCache folder
    Rebuild Solution
    Rebuild Website
    Going to Debug -> Options:
       General - Require source files to exactly match original version is checked
       Edit and Continue - disabled/enabled this
       Symbols - downloaded symbols into cache, emptied cache, reloaded symbols

       Debug -> Projections and Solutions:
          Build and Run -
          On Run, when projects out of date is set to Always Build
          On Run, when build or deployment errors set to Prompt to launch
          For new solutions use the currently selected project as the startup project
    Going to Debug -> Windows -> Modules to confirm modules were loaded during debug
    Going to Debug -> Project Property Pages -> Build and making sure before running start up page was set to Build Web Site
    Under Property Pages of website adding an x86 platform

    Specific to local IIS:

    Stopping and starting IIS
    Stopping and starting IIS Admin service
    Deleting the application on IIS and creating a new one

    Other:

    Reinstalling Visual C++ 2008 Runtime
    debug runs old code from VS forum
    Scary - debug is running old code from VS forum
    How to Change Build Output Directory from MSDN

    Some additional side notes, on that last link I provided, my current Visual Studio environment is set up for Web Development but the instructions apparently are only applicable(?) if VS is set up for C# because I do not have the options listed on the page available to me. I've also noticed one other strange thing in my version of Visual Studio in that the option to Clean Solution is not being provided when I right click on the project; however, that could possibly be related to the type of project. Short of creating a new copy of the project and copy/paste my changes in again, I am not certain how to get past this or prevent it from happening again. Please advise and thank you.

    Thursday, December 27, 2012 8:30 PM

All replies

  • Hi ElaineKhandr,

    Thank you for posting in the MSDN forum.

    Not very sure whether I understand this issue correctly, do you mean that just the web apps have this issue? Could you clean\ rebuild your app in the Solution Explorer? How about deleting the Debug folder in your project, build it, and check it again. Does it work well in other machine?

    In addition, please open the Configuration Manager under “Build” menu, make sure that your project is in the debug mode, and please enable the “Build” for your project. Check it again.

    Have a nice day,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, December 28, 2012 9:47 AM
    Moderator
  • Hi Jack,

    Thanks for your reply. I am only working on web apps, so only those are affected. I looked in the Configuration Manager and the Active Solution Configuration manager is set for Debug and there is a check mark under Build. As mentioned aboved, I have done a rebuild but the 'clean' option is missing from the menu. I also tried to find the Debug folder which I thought would be in the bin folder but there is not one there. Where else would I find the Debug folder?

    Friday, December 28, 2012 1:19 PM
  • Hi ElaineKhandr,

    You could open the “obj” folder, it seems that the “Debug” folder is saved there.

    I have done a rebuild but the 'clean' option is missing from the menu.

    Do you mean that you couldn’t get the “Clean” option when you right click your app in the Solution Explorer? Could you get the “Clean Solution” option under “Build” menu? If have, click it. If not, maybe you could try to check the “Customize” window under “Tools” menu.

    To make sure that you run your app with the default settings, would you please reset your VS settings?

    Tools->Import and Export Settings.

    If still no help, could you check it in other machine? Does it work well? If it worked well, I’m afraid that it would be related to your VS. But if it has the same issue, since it is related to the web apps, my suggestion is that you could post this issue to http://forums.asp.net where asp.net experts live in, and there you would get better support. Thanks for your understanding.

    Have a nice day,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, December 31, 2012 2:41 AM
    Moderator
  • I ma also having this issue.  While debugging an ASP.NET Application, the debugging instances are all throwing errors from code that no longer exists.

    + Used to have a library project, in the web application, refactored and no longer needed it.

    + removed all references to the project, removed the project, removed all usage of the code.

    + the solution builds, the projects all build. 

    + The applications throws on error from code in the library that has been removed. 

    What I have done

    + Clean solution (Several times)

    + deleted temp compilation objects

    + deleted build objects ( rebuilt several times) 

    + killed all Dev web Server pids (several times) 

    + closed Visual studio reopened, no dice.

    + rebooted machine 

    + reopend project and started debugging again. 

    + no luck.

    + Deleted all files in the obj folder ( why didnt clean do this??? I have very old files, and files with mized dates, ranging from minutes ago, to weeks ago, and everything inbetween) 

    + still no luck 

    + Exception page points to code files that no longer exist on the hard drive 

    **It smells like the build is not actually working.  Even though its successful, and reports no errors. Wsa there a recent update to MSBUILD?  It is like build does not create new files from new code. Itsl ike it fails, and produces what it would have produced ( a week ago lets say,) .  All projects in the solution, are set to build. And all produce valid built output in the build results, and also produce valid build artifacts. 

    Publishing the web application to an IIS server, works. There is no issues with the application.  The Library I was using was only used in the Global.asax. There fore while debugging all you got immediately, an error screen with code form a libary that no longer exists. 

    Did the OP get any luck else where? Google brings you here, and I could not find this issue on

    http://forums.asp.net



    Rex Whitten

    Monday, January 21, 2013 8:22 PM
  • It's an old topic but as I had this issue recently with the same config as the OP I'll post my workaround:

    This issue is related to the references. What I do to fix this is remove all added references and re-add them.

    That fixed it for me.

    KR,

    Wim

    Thursday, February 28, 2013 2:09 PM
  • I too am having the same issue. When debugging my app the code that displays in IE is NOT my current code, but code that does not exist anymore, yet there it is...right there in front of me. WTF! I have done many of the steps the previous users have done, with no avail. Please help.
    Tuesday, April 30, 2013 5:21 PM
  • I fixed my issue. I went into my project and modified the server settings to STOP using IIS and to switch to "Visual Studio Development Server". This fixed the problem. See my attached images.

    screenshot

    • Proposed as answer by Alex Dove Tuesday, April 30, 2013 6:43 PM
    Tuesday, April 30, 2013 6:42 PM
  • This issue may not be directly tied to switching from Cassini to IIS. 

    This should be annotated, as a good solution to try. However, the problem really revolves around, Visual Studio using/building  the incorrect assemblies. The "bug" here, is that this issue seems to arise from a very specific set of events.  Visual Studio loses the correct binaries to run, and still maintains artificial integrity within VS, as to the Code -> Assembly relationship.  

    VS: I have Code Base A  from Assembly A

    VS: I have Code Base B from Assembly A  (this is the problem). 

    Other Issues: (these are observations, and not a  complete diagnosis)

     - A solution "Clean" action doesnt resolve this (possible clean error? maybe not)
    - A Rebuild all does not produce new Assemblies. 
    - A Build does not produce new Assemblies. 
    - A Reference that needs to be built (ie referenced Library project), does not rebuild due to error, but the error is not identified. (and therefore gives a false Build Succeed). 

    Solutions
    - Doing something that affects the state and structure of a Solution/Project. 
    - Remove all References, and re add
    - Remove Referenced Projects and re-add 
    - For me, I built a new Solution and added the projects to it. This resolved the issue for me. 


    Final Thoughts 

    - I think there is a bug here, but its hard to reproduce, and doesnt seem to affect alot of people. 


    Rex Whitten

    Tuesday, April 30, 2013 6:56 PM
  • Hitting this as well.  VS shows a "shadow" version of the site.  It pops up a new project in the Solution Explorer called "Script Documents", sub folder Windows Internet Explorer, and then has stale copies of all my files.

    I've tried some of the stuff folks have suggested but some stuff doesn't match so I can't select "Visual Studio Development Server" for instance.

    I'm seeing some different icons for the SCC stuff so I'm wondering if I've somehow boned adding this to TFS.  It also made a bogus project in SCC with suffix _1 instead of using the existing dir.

    Not sure what to search for to learn more about this.  OK, I'll go flail at things like making a new project and stuff.


    Coincidence is the superstition of Western science.

    Wednesday, June 12, 2013 5:11 PM
  • Wow, that was surprising.  I deleted the project and re-made it.  Went to debug.  Still same shadow project with stale code.  No idea where it's coming up with the stale code either.  Bizarre!

    Coincidence is the superstition of Western science.

    Wednesday, June 12, 2013 5:29 PM
  • I have same problem. All project not working (old and new). Trying new project, not working. I need urgent solution.
    Wednesday, July 17, 2013 11:32 PM
  • Hello everyone,

    Basically I'm experiencing the same thing, but I want to add something to the discussion.

    In my case the assemblies are being created in Debug folder, Release folder and are properly deployed in Bin folder on IIS side, msbuild seems to be doing its job but there's a slight problem, if I go to DEBUG > Windows > Modules it came to my attention that the PDB files related to my DLL's that reside in Temporary ASP.NET Files folder are not being loaded with a Symbol status of (Cannot find or open the PDB file.).  

    When I looked to Timestamp column on Modules view, I saw that it never reloads those assemblies on every attempt I made to debug something.

    Is it a VS2012 bug?

    Best regards.


    Do not judge a man until you walk a mile on his feet!

    Wednesday, July 31, 2013 5:20 PM
  • Please, verify following:

    Could you please select Build -> Configuration Manager, on the pop up window, make sure the checkbox in the Build column is ticked.

     

    You can also select  Tools -> Options -> Projects and Solutions -> Build and Run, untick the checkbox of "Only Build startup projects and dependencies on Run", and select Always Build from the "On Run, when project are out of date" dropdown.

    Regards

    • Proposed as answer by Nazza Wednesday, January 08, 2014 11:01 AM
    • Unproposed as answer by Nazza Wednesday, January 08, 2014 11:05 AM
    Saturday, August 10, 2013 9:06 PM
  • This solved my problem... thanks man!!!
    Monday, October 28, 2013 11:16 AM
  • Did not work for me..

    Global.asax.cs does not recognize breakpoints..

    This looks like a mess in the cache management - some assemblies are kept and loaded from cache even after the original assembly changes.

    Monday, March 17, 2014 9:16 AM
  • I am having a similar issue.  I am trying to prototype a user control using VS 2012 and ASP.NET winforms.  I start Visual Studio, open and run the project, it will execute as expected.  When I make a change to the markup or even to the code behind and run it again, the old code executes.  I have tried the solutions mentioned in this post and elsewhere to no avail.  The only thing that seems to fix it for me is to restart Visual Studio every time I make a change.
    • Edited by Nicole Brown Friday, April 04, 2014 5:39 PM typo
    Friday, April 04, 2014 5:38 PM
  • I have this issue "some times". On vs2010, vs2012, and now... again in vs2013. A bit pathetic.

    Try 1: Be sure that your global.asax is in root level, not into a subdirectory.

    Another try: in VS2013, IIS Express it's used. Even if you change the output file for compiled results, you will see in applicationhost.config that IISExpress it's really "looking" to the default bin folder of your project.

    So please destroy manually all content on this folders and compile again.

    VS works in 32 bits. Delete %windir%\microsoft.net\framework\v4.0xxx\Temporary ... 

    Even it's possible that you have different configuration for Debug or Release, so maybe IIS it's looking BIN with Release code, and you are now compiling in Debug to another folder, do you understand me?

    Good luck my friends ;)

    Thursday, April 10, 2014 7:13 AM
  • I have the same problem. Visual Studio 2012/2013 does not detect modified files on build.

    I posted this stating the problem was solved when downgrading from VS2013 to VS2012 with Update 4, but it was not.

    Whenevery I get latest from source control, rebuild and deploy, the cs files are not rebuilt. If I open one of the files updated from source control and make a change and rebuild+deploy, it works.

    I did not have this problem with Visual Studio 2010.

    I can't imagine a more serious bug for the Visual Studio team to investigate than this one: the IDE can't be trusted with builds.



    Tore Olav Kristiansen

    Tuesday, April 15, 2014 8:36 AM
  • Hi Jack Zhai.

    I see you marked your own reply as the anwer. I don't agree that the issue is solved. Visual Studio 2012 and 2013 do not make complete builds.

    If you want to make a deploy package on a developer machine, don't use the aforementioned VS versions. Instead use a build script like below.

    set msbuild="C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe"

    %msbuild% "G:\AcmeSourceCode\Acme\Acme.sln" /t:Rebuild /p:Configuration=Release /p:Platform="Any CPU" /nologo /v:q

    %msbuild% /p:Configuration=Release /m G:\AcmeSourceCode\Acme\Acme.Application.SharePointv4.Solution\Acme.Application.SharePointv4.Solution.csproj /t:Package /p:BasePackagePath=G:\DeployPackages\

    %msbuild% /p:Configuration=Release /m G:\AcmeSourceCode\Acme\Acme.Application.SharePointv4.Solution.Enterprise\Acme.Application.SharePointv4.Solution.Enterprise.csproj /t:Package /p:BasePackagePath=G:\DeployPackages\




    Tore Olav Kristiansen

    Sunday, June 01, 2014 10:55 AM
  • Today I took a copy of my project and started working on it in a new location on my C: drive. When I tried to run it in the browser, just as for the others in this discussion, what was rendered was the previous version which did not reflect my changes.

    To fix this problem I experimented by working on the project from the original location by recreating the folder structure. From that location, all the changes showed in the browser. Of course this isn't a solution but it might be a useful work-around for others to consider until the VS team fix this bug.

    I agree with Tore that I can’t imagine a more serious bug for the VS Team to fix. To help point them in the right direction though, when I published the project that was NOT reflecting my changes, then opened the website using those published files from the test server, the changes showed in the browser!

    Wednesday, July 09, 2014 9:46 AM
  • Friends I had the same issue and I got it sorted it out.

    Go to the project "obj" folder and remove all old files.

    Go to the project "bin" folder and remove all old files.

    Then it works fine. I spent 5 hours to get this going.

    Best of luck. Let me know if it worked for you.

    Sunday, August 10, 2014 5:41 AM
  • There are several ways to resolve this issue once you know it has happened Philip. Restarting VS and then performing a rebuild is perhaps the easiest.

    The big problem here however is that VS builds without errors, but only builds the code that it finds has changed since last. That discovery is flawed. So you are unknowingly left running a limbo-version of the code. If you know about this VS bug, you might figure out after some time what is going on, but if you don’t, the last place you look is VS.

    In my first programming class at the university, some of the fellow students who couldn’t get their code running, claimed there was a bug in the compiler. “Yeah right” I thought to myself. Now Microsoft has actually got a bug in there.


    Tore Olav Kristiansen



    Monday, August 11, 2014 7:58 AM
  • I started this thread to hopefully get some much needed attention to the issue:

    http://social.msdn.microsoft.com/Forums/vstudio/en-US/c76c57d8-e961-47d4-b7c2-59f1f43885ad/visual-studio-2012-debug-runs-old-code?forum=vsdebug


    Tore Olav Kristiansen


    Tuesday, September 09, 2014 10:31 AM
  • I've just had this very same problem.. I restarted my PC, rebuilt the website.. trying all these different things thinking it's a bug or something wrong with the installation...

    Just when I was about to call Microsoft and tell them of this horrific bug that I had found I started thinking a bit more realistic...

    I was debugging code of a textbox.text value going missing in the button click event... thinking it was being wiped by old version code.. It turns out that when I then asked myself what other code is executed upon this event I looked to the Page_Load event and to my shame I saw I was wiping the textbox there all along!

    TIME FOR ANOTHER COFFEE...

    Saturday, January 30, 2016 4:16 PM
  • After 5 years, this bug has not been fixed. I been working with Visual Studio for a couple months and now all of a sudden I get this issue like all of you are having.

    This should have been fixed way earlier, is it not fixable? 


    Monday, August 06, 2018 6:34 AM