Background compilation is a feature of the Visual Studio IDE.  It includes a special version of the language-specific source code compiler that runs continuously on a background worker thread.  Each time you make a change in the code editor, the background compiler wakes up and attempts to compile the code.  This is the feature that’s responsible for the squiggly marks under code in the editor and errors in the Task List while you’re writing code.

Microsoft first introduced background compilation to the Visual Studio.NET 2002 IDE for VB.NET projects.  The other languages did not ship with background compilers.  Most of the time background compilation is a great productivity enhancer, alerting you to your errors immediately.  When you switch back and forth between VB.NET and C#, for instance, you really miss this feature.

Unfortunately, background compilation tends to be the most unstable portion of the IDE.  Have you ever been working in a VB.NET project when the IDE suddenly crashes with “unexpected compiler error?”  Have you had the compiler suddenly begin informing you that variable xyz is not defined, when you’re looking at the declaration on screen?  You’ll find that when you restart the IDE, these errors magically disappear.  These issues are all due to bugs in the background compiler.

The most amazing thing about these bugs is that Microsoft virtually denies that they exist.  At least 80% of the VB.NET projects I’ve worked on have experienced these problems once the code base grows beyond trivial size.  While I was working for Microsoft, I found records of the background compiler bugs in their internal bug tracking database.  There is even a hotfix for Visual Studio.NET 2002 and 2003 that addresses some of them.  However, this hotfix was never made publicly available.  We eventually obtained it from Microsoft PSS, and I’ve carried it with me from client to client ever since.  It doesn’t fix all the bugs, but it’s better.  It amazes me that there was never a service pack for VS.NET 2003.  I’ve heard that one may be coming — now that Visual Studio 2005 is released and people are moving away from 2003.

With the introduction of Visual Studio 2005, both VB.NET and C# include background compilation.  And guess what?  Reports are already coming in [more] that the C# background compiler crashes in certain situations, some involving the use of generics.  Thankfully they also added AutoSave to the 2005 IDE.  The unofficial timeline for Visual Studio 2005 SP1 is sometime in mid-2006.

In short, background compilation is a great productivity enhancer, but is not without its problems.