Prevent Visual Studio from running programs with syntax errors

If a program’s code contains syntax errors, then by default if you try to run the program Visual Studio displays the following message:

You should pretty much always click No. If you click Yes, an older version of the program runs so you won’t see any of the changes that you recently made and you may incorrectly think the new code works properly. (This is a common beginner mistake.)

To prevent Visual Studio from even asking if you want to run the old version, follow these steps:

  1. Open the Tools menu and select Options.
  2. Expand the Options tree to go to Projects and Solutions > Build and Run. On the right, set “On Run, when build or deployment errors occur” to “Do not launch.”

Now if you have syntax errors, Visual Studio displays them in the Error window, doesn’t launch the old version of the program, and doesn’t waste your time with the message box.

Follow me on Twitter   RSS feed   Donate

This entry was posted in IDE and tagged , , , , , , , , , . Bookmark the permalink.