Reputation: 3
When executing any code in the Visual Studio console, if there is an error in my code instead of displaying an error message it simply displays the most recent correct output, even if the code for it has been deleted, is there a setting that I accidentally turned on that is doing this? If so, how can I disable it?
I am using Visual Studio 2019, C#, console app. I have tried saving the new code then running it but that doesn't make a difference, I've tried quiting out of the app and reopening it or switching to a new project and that doesn't work either.
If I were to type:
Console.WriteLine("Hello world!");
Console.ReadLine();
which is correct code, it will display: Hello world!
If I then were to change it to:
Console.WriteLine("Goodbye world")
Console.ReadLine()
Instead of giving me an error message, since I forgot the semicolons, it would just print: Hello world! again.
I would expect there to be an error message instead of what happens since the previous program I used did that.
Ps: Sorry if this question is obvious or self explanatory or if it's just me who is wrong but it's really stressing me out seeing correct output from the wrong code.
Upvotes: 0
Views: 409
Reputation: 1600
I believe you're looking for Tools->Options->Projects and Solutions->Build And Run.
The default (which fails build on error) is what you see on screen (On Run, when build or deployment errors occur part):
The one that you're using now and trying to get rid of, most likely, is "Launch old version".
Upvotes: 3