0

I'm making an ASP .NET project using MVC, I've been having a recurring glitch in visual studio when I try debugging recently added code, when I add a breakpoint to a method in which I have added new code and I try debugging that method, the debugger skips the new code and only debugs the old code. It's like the code stayed in an older version and visual studio won't detect new code. Any idea what this might be?

This is a method in which I have added new code as an example:

        public ActionResult EnviarCorreo()
        {
            bool num;

            num = false;

            if (num == true)
            { 
                clsCotizacion ObjCotizacion = new clsCotizacion();
                ViewBag.Lista = ObjCotizacion.ConsultaCorreoProveedor().ToList();
                return View();
            }
        return View("Index");
        }

The new code is:

bool num;

num = false;

   if (num == true)
        { 
        //the code inside this if is old
        } 
        return View("Index");

As you can see, if this were to be executed, the method wouldn't be able to run the code inside "if (num == true)" because I've set the value of num to false, yet the code is still executed because visualstudio skips the newly added code, so it jumps straight to "clsCotizacion ObjCotizacion = new clsCotizacion();". I should also mention that when debugging step by step, the positions of the lines of the debugger are still the same as the ones in the old method.

J Becu
  • 31
  • 2
  • 4

1 Answers1

0

It sounds like you might not actually be calling the new code, where the new breakpoints are.

This thread looks like a similar issue to yours as well: Visual Studio breakpoints not being hit see if that answers your question!

Pavel
  • 72
  • 3
  • 1
    The solution configuration is set to Debug and the solution platform is set to any CPU, the new code is still not debugged or executed at all. I'll edit the original question to show an example of the problem. – J Becu Jul 17 '20 at 21:36