views:

27

answers:

2

My Error List is not populating if I code something that should be a compiler error. When I go to run the program I finally see the build errors in the Error List. If I fix the code, the errors do not disappear from the Error List until I run again. I can't find the option driving this behaviour. It only does this when I'm working in a C# project on my work pc. The Error List updates at code time for VB or for both language on my home pc (the behaviour I want).

A: 

In VB and C#, the IDE picks up a lot of errors as you type and they appear and disappear in the error list as you write the code. However, there are many more errors that the IDE cannot pick up until it spends time actually processing (compiling) the code - it would slow the IDE down too much to continually build in the background to detect these errors, so it only looks for them when you specifically ask it to.

In addition, these errors remain in the list so that you can refer back to them, until you decide to manually refresh the list. (I find this a useful behaviour because when errors just disappear from the list I lose my place, which I find very irritating)

You don't need to try to run the program to refresh the errors - just run the Build command to rebuild the code and refresh the error list. You will need to get in the habit of pressing ctrl+shift+B (or whichever key binding is assigned to build on your system) whenever you wish to check your code and update the error list. Usually the builds are quick, so after a while you will find yourself pressing ctrl+shift+B after writing a few lines of code to verify that it is error free before you go on and write more. It may seem like a pain at first, but it'll soon become an unconscious habit.

Jason Williams
Good point about the errors not clearing being useful. I could see temporarily disabling the auto show/clear errors if I break something huge on purpose so I can keep navigating to all the affected areas whether they are fixed or not.
eric1825
+1  A: 

VB has a background compiler working all the time to compile your code "on the fly", and show you those errors. C# didn't, until VS2008 SP1. Do you have 2008 SP1 installed?

EDIT: Also, if you do have SP1 installed, there are some options to control this. Go to Tools -> Options -> Text Editor -> C# -> Advanced, and check the box that says "Show live semantics errors"

Rick Mogstad
More details on this change in SP1 can be found here: http://codebetter.com/blogs/david.hayden/archive/2008/05/13/visual-studio-2008-sp1-quot-background-compiling-quot-for-c.aspx
Saul Dolgin
Actually, background syntax checking works for C# in VS2005 and VS2008, (although with each version this facility has improved). e.g. Even in VS2005 if you write an if statement with mismatched brackets, the error list will be updated live as you type.
Jason Williams
I did not have VS2008 SP1. After I installed it the c# "Show live semantics errors" option appeared and was on by default. I should have asked months ago. Thanks!
eric1825