question

mbedell1 avatar image
0 Votes"
mbedell1 asked mbedell1 commented

Visual Studio 2017 Builds the code but runs a previous version.

I have been working on a ASP.Net Web project (.Net 4.6.1) that was running fine on Friday. When I came in on Monday I made some small code changes to one page and tried to run the project to see what my changes would do. The project built and appeared to run but it didn't hit my break point. I put in several break points, one of them even at the default Page_Load and it never stopped. After much trial and error it appears that it is not actually running the code that it built but is instead running a previous build. How can I force it to run what it just built?

dotnet-csharpvs-debugging
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

What are you debugging the project against? IIs Express or local IIS? Did you do a 'Clean' and 'Build' of the solution?

0 Votes 0 ·
mbedell1 avatar image mbedell1 DuaneArnold-0443 ·

I'm using the Local IIS in VS 2017.

0 Votes 0 ·

I got the breaks to work but it's strange. I created a new function for a button click and it added it to the end of my code behind page (as normal) . I ran the code and the break worked. I moved the function up to where all the other functions are and it stopped working. Moved it back and the breaks work.
Left it where it works and added code inside: a foreach loop which only partially works. it gets the GridView.Rows but doesn't assign them and only does one of the ten rows.

0 Votes 0 ·

Good to hear things are working but still sounds like there is a bug someplace. By adding code sounds like msbuild recognized changes and did a proper build.

0 Votes 0 ·

It appears there is more wrong with whatever is going on than I originally thought. I stopped everything and started a new project where I will import (one page at a time) everything I have been doing. Things got that bad. So far everything with the new rebuild is work just fine, so it's possible there was something wrong with the Project/solution.
I appreciated all of your help on this issue and I'm sorry that the actual problem wasn't what I stated above. The solution to this problem seems to be Upgrade to VS 2019.

0 Votes 0 ·
karenpayneoregon avatar image
0 Votes"
karenpayneoregon answered mbedell1 commented

Close Visual Studio, in windows explorer, delete the obj and bin folders. Open Visual Studio to you project then in Solution Explorer right click, select configuration manager and verify the build is checked on the project. Do a clean then Rebuild the solution, watch for issues in the output window. See if that helps or not.

Have you tried rebooting your computer too?

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I tried all that and I have seen that work in the past but it didn't this time. I also made a visual change to the code so that I could see if it would put it on screen and it did. So maybe the build is being run after all. However, it wont stop on any of my breaks and is giving me an error that it can't find the object or object has not been defined. That's not surprising since the change I made was to remove that code. It was breaking because it was trying to run a function that existed but from a button that no longer existed and was never hit in the first place. I removed the function but it still acts like it's there. As I said it doesn't hit any break points either.
I added some text just just to see if it would show up on the screen and it did. I removed it and it went away. So it seems to be building and running the same code it just acts like it's not doing it in debug mode. Is there somewhere where this can be turned on or off?

0 Votes 0 ·
  • Verify that you are building in debug mode not release

  • Try disable the "Just My Code" option in the Debugging/General settings.


0 Votes 0 ·
mbedell1 avatar image mbedell1 karenpayneoregon ·

Tried that and it just got worse.

0 Votes 0 ·
DylanZhu-MSFT avatar image
0 Votes"
DylanZhu-MSFT answered

Hi mbedell1,

According to your description, this issue may be caused by the browser caches. You can try to follow these steps from this answer to disable browser caches, then re-debug your web application:

  1. Click Browse with... in the toolbar
    82601-image.png

  2. Copy the path of the browser you need , then click Add
    82598-image.png

  3. Paste the path of browser and add --disk-cache-dir=null in Arguments
    82576-image.png

Best Regards,
Dylan


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


image.png (15.8 KiB)
image.png (15.7 KiB)
image.png (8.1 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DuaneArnold-0443 avatar image
0 Votes"
DuaneArnold-0443 answered DuaneArnold-0443 edited

@mbedell1

Well, the Web project code does not match the binary that has been pushed out to IIS is why the breakpoints are not being hit along with any other problems you are having.

I suggest that you do a clean and rebuild, which should push the project out to local IIS.

You can also just go to IIS and delete the Web site off of IIS, do a project clean and rebuild and push the solution back out to local IIS.

The link may help.

https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-enable-debugging-for-aspnet-applications?view=vs-2017

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.